#include <bits/stdc++.h>
using namespace std;
const int maxn = 150005;
int a[maxn], n, used[maxn] = {0};
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) {
    for (int j = -1; j <= 1; j++) {
      int x = a[i] + j;
      if (x > 0 && !used[x]) {
        used[x] = 1;
        break;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i < maxn; i++) {
    if (used[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}
