#include <bits/stdc++.h>
const long long mod = 1e9 + 7, inf = 1e9, linf = 1 << 30;
const long long hashmod[4] = {(int)1e9 + 2277, (int)1e9 + 5277, (int)1e9 + 8277,
                              (int)1e9 + 9277};
const long double EPS = 0.000000001L, pi = acos(-1);
using namespace std;
using namespace std;
int cnt[150002];
int main() {
  int n;
  cin >> n;
  vector<int> f(n);
  for (auto& z : f) cin >> z;
  sort(f.begin(), f.end());
  for (auto z : f) {
    int tm = z;
    int tml = z - 1;
    int tmr = z + 1;
    if (tm != 1 && cnt[tml] == 0)
      cnt[tml] = 1;
    else {
      if (cnt[tm] == 0)
        cnt[tm] = 1;
      else
        cnt[tmr] = 1;
    }
  }
  int res = 0;
  for (int i = 1; i <= 150001; i++) {
    res += (cnt[i] > 0) ? 1 : 0;
  }
  cout << res;
}
