#include <bits/stdc++.h>
const long long mod = 1000000007;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  set<long long> s;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  for (long long i = 0; i < n; i++) {
    if (arr[i] == 1 and s.find(1) == s.end())
      s.insert(1);
    else if (arr[i] == 1 and s.find(1) != s.end())
      s.insert(2);
    else if (s.find(arr[i] - 1) == s.end())
      s.insert(arr[i] - 1);
    else if (s.find(arr[i]) == s.end())
      s.insert(arr[i]);
    else if (s.find(arr[i] + 1) == s.end())
      s.insert(arr[i] + 1);
  }
  cout << s.size() << endl;
}
