#include <bits/stdc++.h>
using namespace std;
int n;
long long a[150000 + 10];
bool ans[150000 + 10];
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    memset(ans, false, sizeof(ans));
    for (int i = 1; i <= n; i++) {
      if (a[i] - 1 >= 1 && !ans[a[i] - 1]) {
        ans[a[i] - 1] = true;
        continue;
      } else if (!ans[a[i]]) {
        ans[a[i]] = true;
        continue;
      } else if (a[i] + 1 >= 1 && !ans[a[i] + 1]) {
        ans[a[i] + 1] = true;
        continue;
      }
    }
    long long sum = 0;
    for (int i = 1; i <= 150000 + 5; i++) {
      if (ans[i]) {
        sum++;
      }
    }
    cout << sum << endl;
  }
}
