#include <bits/stdc++.h>
using namespace std;
const long long LINF = 0xfffffffffffffff;
const int INF = 1 << 29;
int main() {
  int n, ma = 0;
  int a, f[150005];
  memset(f, 0, sizeof(f));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    f[a]++;
    if (a > ma) ma = a;
  }
  int ans = 0;
  for (int i = 1; i <= ma + 1; i++) {
    if (f[i - 1]) {
      f[i - 1]--;
      ans++;
    } else if (f[i]) {
      f[i]--;
      ans++;
    } else if (f[i + 1]) {
      f[i + 1]--;
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
