#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long a[200200], t[200200];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) {
    if (t[a[i] - 1] == 0 && a[i] - 1 > 0) {
      k++;
      t[a[i] - 1] = 1;
    } else if (t[a[i]] == 0) {
      k++;
      t[a[i]] = 1;
    } else if (t[a[i] + 1] == 0) {
      k++;
      t[a[i] + 1] = 1;
    }
  }
  cout << k;
}
