#include <bits/stdc++.h>
using namespace std;
long long int n, i, m, c;
long long int ar[1500005], br[1500005];
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> br[i];
  }
  sort(br, br + n);
  for (i = 0; i < n; i++) {
    m = br[i];
    if (m != 1 && ar[m - 1] == 0) {
      c++;
      ar[m - 1] = 1;
    } else if (ar[m] == 0) {
      c++;
      ar[m] = 1;
    } else if (ar[m + 1] == 0) {
      c++;
      ar[m + 1] = 1;
    }
  }
  cout << c << endl;
  return 0;
}
