#include <bits/stdc++.h>
using namespace std;
const int MAXN = 150005;
int num[MAXN];
int main() {
  int n, x;
  scanf("%d", &n);
  memset(num, 0, sizeof(num));
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    num[x]++;
  }
  for (int i = 2; i <= 150000; i++) {
    if (num[i] >= 1 && num[i - 1] == 0) {
      num[i]--;
      num[i - 1]++;
    }
  }
  for (int i = 150000; i >= 1; i--) {
    if (num[i] >= 1 && num[i + 1] == 0) {
      num[i + 1]++;
      num[i]--;
    }
  }
  int sum = 0;
  for (int i = 1; i <= 150001; i++) {
    if (num[i] != 0) {
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}
