#include <bits/stdc++.h>
const int INF = 1 << 29;
int cmp(const void* a, const void* b);
long long maxv(long long a, long long b);
long long minv(long long a, long long b);
long long gcd(long long u, long long v);
int main() {
  long long n;
  scanf("%lld", &n);
  long long arr[n], ans = 0;
  int count[150005] = {0};
  for (long long i = 0; i < (n); i++) scanf("%lld", &arr[i]);
  qsort(arr, n, sizeof(arr[0]), cmp);
  for (long long i = 0; i < (n); i++) {
    long long x = maxv(1, arr[i] - 1);
    if (count[x] == 0) {
      count[x] = 1;
      ans++;
    } else if (count[x + 1] == 0) {
      count[x + 1] = 1;
      ans++;
    } else if (count[x + 2] == 0) {
      count[x + 2] = 1;
      ans++;
    }
  }
  printf("%lld\n", ans);
}
int cmp(const void* a, const void* b) {
  if (*(long long*)a - *(long long*)b < 0) return -1;
  if (*(long long*)a - *(long long*)b > 0) return 1;
  return 0;
}
long long maxv(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long minv(long long a, long long b) {
  if (a < b) return a;
  return b;
}
long long gcd(long long u, long long v) {
  if (v == 0) return u;
  return gcd(v, u % v);
}
