#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1010;
int a[N];
int main(){
int n; scanf("%d", &n);
for(int i = 0; i < n; i ++ ) scanf("%d", &a[i]);
sort(a, a + n);
int cnt = 0;
for(int i = 1; i < n; i ++ ){
if(a[i] - a[i - 1] == 1) cnt ++ ;
}
cout << cnt << endl;
return 0;
}