#include <bits/stdc++.h>
using namespace std;
const int MAXN = 150005;
int a[MAXN];
int num[MAXN];
bool vis[MAXN];
int n, m, ans;
int main() {
  memset(vis, 0, sizeof(vis));
  memset(num, 0, sizeof(num));
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    num[a[i]]++;
  }
  sort(a, a + n);
  m = unique(a, a + n) - a;
  ans = 0;
  for (int i = m - 1; i >= 0; i--) {
    for (int j = 1; j >= -1 && num[a[i]] > 0; j--) {
      if (a[i] + j > 0 && !vis[a[i] + j]) {
        vis[a[i] + j] = true;
        num[a[i]]--;
        ans++;
      }
    }
  }
  printf("%d", ans);
  return 0;
}
