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