#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, i, j, ans = 0;
  cin >> n;
  vector<long long int> a(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long int lst = 0;
  for (i = 0; i < n; i++) {
    long long int cur = -1;
    for (j = -1; j <= 1; j++)
      if (a[i] + j > lst) {
        cur = a[i] + j;
        break;
      }
    if (cur == -1) continue;
    ans++;
    lst = cur;
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
