#include <bits/stdc++.h>
using namespace std;
long long arr[1000001];
long long cnt[1000001];
vector<long long> crr;
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  long long n, m, k, a, b, c, ans = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  for (int i = 0; i < n; ++i) {
    if (arr[i] != 1 && cnt[arr[i] - 1] == 0)
      cnt[arr[i] - 1] = 1;
    else if (cnt[arr[i]] == 0)
      cnt[arr[i]] = 1;
    else if (cnt[arr[i] + 1] == 0)
      cnt[arr[i] + 1] = 1;
  }
  a = 0;
  for (int i = 1; i <= arr[n - 1] + 1; ++i) {
    if (cnt[i] > 0) a++;
  }
  cout << a << endl;
  return 0;
}
