#include <bits/stdc++.h>
using namespace std;
int n;
int cnt[150010];
int org[150010];
int lst[150010];
int x;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  while (n--) {
    cin >> x;
    cnt[x]++;
    org[x] = cnt[x];
  }
  int last;
  for (int i = 0; i <= 150001; i++) {
    if (cnt[i] == 0) last = i;
    lst[i] = last;
  }
  for (int i = 150001; i >= 1; i--) {
    if (org[i] > 1) {
      if (!cnt[lst[i]]) {
        cnt[lst[i]] = 1;
        cnt[i]--;
      }
    }
    if (cnt[i] == 0) {
      if (cnt[i - 1] >= 1) {
        cnt[i - 1]--;
        cnt[i]++;
      }
    }
  }
  int res = 0;
  for (int i = 1; i <= 150001; i++) res += (cnt[i] != 0);
  cout << res << endl;
  return 0;
}
