#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b, long long int m) {
  if (b == 0) return (1);
  long long int sol = power(a, b / 2, m);
  sol = (sol * sol) % m;
  if (b % 2 == 1) sol = (sol * a) % m;
  return (sol);
}
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else {
    return gcd(b, a % b);
  }
}
int a[1000001];
set<int> sol;
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  a[n - 1]++;
  for (int i = n - 2; i >= 0; i--) {
    if (a[i] + 1 < a[i + 1])
      a[i]++;
    else {
      if (a[i] == 1) break;
    }
  }
  if (a[0] != 1) a[0]--;
  for (int i = 1; i < n; i++) {
    if (a[i] - 1 > a[i - 1]) a[i]--;
  }
  for (int i = 0; i < n; i++) {
    sol.insert(a[i]);
  }
  cout << sol.size();
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
