#include <bits/stdc++.h>
using namespace std;
const int N = 150001;
int a[N], vis[N];
int main() {
  int n;
  while (cin >> n) {
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    memset(vis, 0, sizeof(vis));
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      if (vis[a[i] - 1] == 0 && a[i] != 1)
        vis[a[i] - 1] = 1, ans++;
      else if (vis[a[i]] == 0)
        vis[a[i]] = 1, ans++;
      else if (vis[a[i] + 1] == 0)
        vis[a[i] + 1] = 1, ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
