#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int SUM = 0, ff = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    SUM = (SUM << 3) + (SUM << 1) + (ch ^ 48);
    ch = getchar();
  }
  return SUM * ff;
}
const int N = 150010;
bool have[N];
int boxer[N];
int n, ans;
int main() {
  n = read();
  for (int i = 1; i <= n; i++) boxer[i] = read();
  sort(boxer + 1, boxer + n + 1);
  for (int i = 1; i <= n; i++) {
    if (boxer[i] - 1 > 0 && !have[boxer[i] - 1]) {
      ans++;
      have[boxer[i] - 1] = 1;
      continue;
    }
    if (!have[boxer[i]]) {
      ans++;
      have[boxer[i]] = 1;
      continue;
    }
    if (!have[boxer[i] + 1]) {
      ans++;
      have[boxer[i] + 1] = 1;
      continue;
    }
  }
  printf("%d\n", ans);
  return 0;
}
