#include <bits/stdc++.h>
using namespace std;
const int N = 5000007;
int a[N];
void solve() {
  map<int, int> MP;
  multiset<int> ans;
  int n;
  long long kns = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    ans.insert(a[i]);
  }
  for (auto i = ans.begin(); i != ans.end(); ++i) {
    if (MP[*i - 1] == 0 && *i - 1 > 0) {
      MP[*i - 1]++;
      kns++;
    } else if (MP[*i] == 0)
      kns++, MP[*i]++;
    else if (MP[*i + 1] == 0) {
      MP[*i + 1]++;
      kns++;
    }
  }
  cout << kns << endl;
}
int main() {
  solve();
  return 0;
}
