#include <bits/stdc++.h>
using namespace std;
int n, mas[150010];
int main(int argc, const char* argv[]) {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> mas[i];
  }
  sort(mas, mas + n);
  if (mas[0] > 1) mas[0]--;
  for (int i = 1; i < n; i++) {
    if (mas[i] > mas[i - 1] + 1) {
      mas[i]--;
    } else if (mas[i] == mas[i - 1] && (i >= n - 1 || mas[i] < mas[i + 1])) {
      mas[i]++;
    }
  }
  sort(mas, mas + n);
  int cnt = 1;
  for (int i = 1; i < n; i++)
    if (mas[i] != mas[i - 1]) cnt++;
  cout << cnt << endl;
  return 0;
}
