#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v;
  int tmp;
  for (int c1 = 0; c1 < n; c1++) {
    cin >> tmp;
    v.push_back(tmp);
  }
  sort(v.begin(), v.end());
  int arr[150002] = {0}, cnt = 0;
  for (int c1 = 0; c1 < n; c1++) {
    if (v[c1] != 1 && arr[v[c1] - 1] != 1) {
      arr[v[c1] - 1] = 1;
      cnt++;
    } else if (arr[v[c1]] != 1) {
      arr[v[c1]] = 1;
      cnt++;
    } else if (arr[v[c1] + 1] != 1) {
      arr[v[c1] + 1] = 1;
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
