#include <bits/stdc++.h>
using namespace std;
const int N = 150005;
bool unq[N];
int main() {
  vector<int> arr(N);
  memset(unq, 0, sizeof(unq));
  int n, res = 0;
  cin >> n;
  for (int i = 0; i < (int)(n); ++i) cin >> arr[i];
  sort(arr.begin(), arr.begin() + n);
  for (int i = 0; i < (int)(n); ++i) {
    if (arr[i] - 1 != 0 && !unq[arr[i] - 1]) {
      unq[arr[i] - 1] = 1;
      ++res;
    } else if (!unq[arr[i]]) {
      unq[arr[i]] = 1;
      ++res;
    } else if (!unq[arr[i] + 1]) {
      unq[arr[i] + 1] = 1;
      ++res;
    }
  }
  cout << res;
  return 0;
}
