#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 5, inf = 1e18;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  long long int ary[n];
  for (long long int i = 0; i < n; ++i) cin >> ary[i];
  sort(ary, ary + n);
  map<long long int, long long int> M;
  long long int cnt = 0;
  for (long long int i = n - 1; i >= 0; i--) {
    if (M.count(ary[i] + 1) == 0) {
      M[ary[i] + 1] == 1;
      cnt++;
    } else if (M.count(ary[i]) == 0) {
      M[ary[i]] = 1;
      cnt++;
    } else {
      if (ary[i] >= 2 && M.count(ary[i] - 1) == 0) {
        M[ary[i] - 1] = 1;
        cnt++;
      }
    }
  }
  cout << cnt << "\n";
  return 0;
}
