#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  if (x < 0) return -x;
  return x;
}
template <class T>
T sqr(T a) {
  return a * a;
}
const double pi = acos(-1.0);
const double eps = 1e-8;
int ar[150010];
int flag[150010];
int i, n;
int main() {
  while (1 == scanf("%d", &n)) {
    memset(flag, 0, sizeof flag);
    for (i = 0; i < n; i++) scanf("%d", &ar[i]);
    sort(&ar[0], &ar[n]);
    for (i = 0; i < n; i++) {
      if (flag[ar[i] - 1] == 0 && ar[i] > 1)
        flag[ar[i] - 1]++;
      else if (flag[ar[i]] == 0)
        flag[ar[i]]++;
      else if (flag[ar[i] + 1] == 0)
        flag[ar[i] + 1]++;
    }
    int cnt = 0;
    for (i = 1; i <= 150001; i++)
      if (flag[i]) cnt++;
    printf("%d\n", cnt);
  }
  return 0;
}
