#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  set<long long> s;
  for (long long i = 0; i < n; i++) {
    long long temp = arr[i];
    if (temp - 1 > 0 && s.find(temp - 1) == s.end())
      s.insert(temp - 1);
    else if (s.find(temp) == s.end())
      s.insert(temp);
    else if (s.find(temp + 1) == s.end())
      s.insert(temp + 1);
  }
  cout << s.size() << "\n";
  return 0;
}
