#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  a[n - 1]++;
  set<int> s;
  s.insert(a[n - 1]);
  for (int i = n - 2; i >= 0; i--) {
    int l = s.size();
    a[i]++;
    int val = a[i];
    s.insert(val);
    if (s.size() > l) continue;
    if (s.size() == l) {
      val--;
      a[i] = val;
      s.insert(val);
    }
    if (s.size() == l) {
      val--;
      a[i] = val;
      if (a[i] < 1) break;
      s.insert(val);
    }
  }
  for (auto it = s.begin(); it != s.end(); it++) {
    if ((*it) < 1)
      s.erase(it);
    else
      break;
  }
  cout << s.size() << endl;
  return 0;
}
