#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, i;
  cin >> n;
  int a[n];
  map<int, bool> mp;
  for (i = 0LL; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int cnt = 0;
  for (i = 0LL; i < n; i++) {
    if (mp[a[i] - 1] == 0 && a[i] != 1) {
      mp[a[i] - 1] = 1;
      cnt++;
    } else if (mp[a[i]] == 0) {
      mp[a[i]] = 1;
      cnt++;
    } else if (mp[a[i] + 1] == 0) {
      mp[a[i] + 1] = 1;
      cnt++;
    }
  }
  cout << cnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc = 1;
  while (tc--) {
    solve();
  }
  return 0;
}
