#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> A(n);
  for (int& a : A) scanf("%d", &a);
  sort(A.begin(), A.end());
  int m = A[n - 1];
  vector<bool> B(m + 2);
  for (int a : A) {
    if (a > 1 && !B[a - 1])
      B[a - 1] = true;
    else if (!B[a])
      B[a] = true;
    else if (!B[a + 1])
      B[a + 1] = true;
  }
  printf("%lu\n", count(B.begin(), B.end(), true));
}
