#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dx[8] = {1, -1, 0, 0, -1, -1, 1, 1};
int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
vector<int> adj[100010], vis(100010, 0), dis(100010, 0), par(100010, 0);
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
bool solve(string s, string t) {
  int i = 0, j = 0, n1 = (int)s.length(), n2 = (int)t.length();
  while (i < n1 && j < n2) {
    if (s[i] == t[j]) {
      i++;
      j++;
    } else {
      i++;
    }
  }
  if (j != (int)t.length()) {
    return false;
  } else {
    return true;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  multiset<int> mt;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    mt.insert(a);
  }
  int cnt = 0;
  for (int i = 1; i <= 150001; i++) {
    if (mt.find(i - 1) != mt.end()) {
      cnt++;
      mt.erase(mt.find(i - 1));
      continue;
    }
    if (mt.find(i) != mt.end()) {
      cnt++;
      mt.erase(mt.find(i));
      continue;
    }
    if (mt.find(i + 1) != mt.end()) {
      cnt++;
      mt.erase(mt.find(i + 1));
      continue;
    }
  }
  cout << cnt << '\n';
}
