#include <bits/stdc++.h>
using namespace std;
int cnt[150004];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  set<int> s;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    cnt[x]++;
    s.insert(x);
  }
  for (auto &it : s) {
    if (cnt[it] == 1) {
      if (it > 1 and !cnt[it - 1]) cnt[it - 1]++, cnt[it] = 0;
    } else if (cnt[it] == 2) {
      if (it == 1)
        cnt[it + 1]++;
      else {
        if (!cnt[it - 1]) {
          cnt[it - 1]++;
          cnt[it]--;
        } else
          cnt[it + 1]++, cnt[it]--;
      }
    } else
      cnt[it - 1]++, cnt[it + 1]++;
  }
  int ans = 0;
  for (int i = 1; i <= 150002; i++) ans += (cnt[i] > 0);
  cout << ans;
}
