#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ar[n];
  for (int i = 0; i < n; i++) cin >> ar[i];
  map<int, int> m;
  for (int i = 0; i < n; i++) m[ar[i]]++;
  m[0] = 3;
  map<int, int>::iterator it = m.begin(), tmp;
  int ans = 0;
  it++;
  while (it != m.end()) {
    int p = it->second, k = it->first;
    tmp = m.find(k - 1);
    if (tmp == m.end() or tmp->second == 0) {
      p--;
      m[k - 1]++;
      m[k]--;
    }
    if (p > 1) {
      m[k + 1]++;
      m[k]--;
    }
    it++;
  }
  it = m.begin();
  it++;
  while (it != m.end()) {
    if (it->second > 0) ans++;
    it++;
  }
  cout << ans << endl;
  return 0;
}
