#include <bits/stdc++.h>
using namespace std;
long long arr[150005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long prev = 2134234;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  sort(arr, arr + n);
  int count_ = 0;
  for (int i = n - 1; i > -1; --i) {
    if (prev > arr[i] + 1) {
      ++count_;
      prev = arr[i] + 1;
    } else if (prev > arr[i]) {
      ++count_;
      prev = arr[i];
    } else if (prev > arr[i] - 1 && arr[i] - 1 > 0) {
      ++count_;
      prev = arr[i] - 1;
    }
  }
  cout << count_ << '\n';
}
