#include <bits/stdc++.h>
using namespace std;
template <class C>
void min_self(C &a, C b) {
  a = min(a, b);
}
template <class C>
void max_self(C &a, C b) {
  a = max(a, b);
}
long long mod(long long n, long long m = 1000000007) {
  n %= m, n += m, n %= m;
  return n;
}
const int MAXN = 1e5 + 5;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int fr[150005] = {};
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    fr[x]++;
  }
  int cnt = 0;
  for (int i = 1; i <= 150001; i++) {
    if (fr[i - 1]) {
      cnt++;
      fr[i - 1]--;
    } else if (fr[i]) {
      cnt++;
      fr[i]--;
    } else if (fr[i + 1]) {
      cnt++;
      fr[i + 1]--;
    }
  }
  cout << cnt, cout << "\n";
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
