#include <bits/stdc++.h>
using namespace std;
template <class T>
void printQueue(T& q) {
  while (!q.empty()) {
    cout << q.top() << endl;
    q.pop();
  }
}
bool prime[1000009];
int d[1000009];
void seive() {
  for (int i = 2; i <= 1000009; i++) {
    if (prime[i] == true) {
      d[i] = i;
      for (int j = i + i; j <= 1000009; j = j + i) {
        if (prime[j] == true) {
          d[j] = i;
          prime[j] = false;
        }
      }
    }
  }
}
long long power(long long a, long long b) {
  long long r = 1;
  while (b != 0) {
    if (b % 2 != 0) {
      r = r * a;
    }
    a = a * a;
    b = b / 2;
  }
  return r;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  memset(prime, true, sizeof(prime));
  while (t--) {
    int n;
    cin >> n;
    int ast[n + 1];
    for (int i = 1; i <= n; i++) {
      cin >> ast[i];
    }
    sort(ast + 1, ast + n + 1);
    bool d[150009];
    memset(d, false, sizeof(d));
    if (ast[1] == 1) {
      d[1] = true;
    } else {
      d[ast[1] - 1] = true;
    }
    int cn = 1;
    d[0] = true;
    for (int i = 2; i <= n; i++) {
      if (d[ast[i] - 1] == false) {
        d[ast[i] - 1] = true;
        cn += 1;
      } else if (d[ast[i]] == false) {
        d[ast[i]] = true;
        cn += 1;
      } else if (d[ast[i] + 1] == false) {
        d[ast[i] + 1] = true;
        cn += 1;
      }
    }
    cout << cn << endl;
  }
}
