#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1010;
int a[N];
bool is_true(int x,int y){
if (y-x == 1) return true;
else return false;
}
int main(){
int n;cin>>n;
int cnt = 0;
for (int i = 0; i< n;i++){
cin>>a[i];
}
sort(a,a+n);
for (int i = 0;i<n-1;i++ ){
if (is_true(a[i],a[i+1])) cnt++;
}
cout<<cnt<<endl;
return 0;
}