#include <bits/stdc++.h>
using namespace std;
long long scanll() {
  long long res;
  scanf("%lld", &res);
  return res;
}
int main() {
  vector<int> inp(150003, 0);
  long long n = scanll();
  for (int i = 0; i < n; ++i) {
    long long w = scanll();
    inp[w] += 1;
  }
  long long seg_start = 1;
  long long seg_end = 1;
  long long pos = 1;
  while (pos <= 150001) {
    long long extra = 0;
    while (pos <= 150001 && inp[pos] == 0) pos++;
    seg_start = pos;
    while (pos <= 150001 && inp[pos] > 0) {
      seg_end = pos;
      extra += inp[pos] - 1;
      pos++;
    }
    pos++;
    if (extra == 1) {
      if (seg_start == 1 || inp[seg_start - 1] > 0) {
        inp[seg_end + 1] += 1;
      } else {
        inp[seg_start - 1] += 1;
      }
    }
    if (extra >= 2) {
      inp[seg_end + 1] += 1;
      inp[seg_start - 1] += 1;
    }
  }
  long long res = 0;
  for (int i = 1; i < 150002; ++i) {
    if (inp[i] > 0) ++res;
  }
  printf("%lld\n", res);
}
