#include <bits/stdc++.h>
using namespace std;
int n, a[150005], cnt;
unordered_set<int> b;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  cnt = n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  if (a[0] > 1) a[0]--;
  b.insert(a[0]);
  for (int i = 1; i < n; i++) {
    if (a[i] > 1 && b.insert(a[i] - 1).second)
      ;
    else if (b.insert(a[i]).second)
      ;
    else if (b.insert(a[i] + 1).second)
      ;
    else
      cnt--;
  }
  cout << cnt << endl;
  return 0;
}
