#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  std::sort(a.begin(), a.end());
  std::vector<bool> seen(150002, false);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] - 1 > 0 && !seen[a[i] - 1]) {
      seen[a[i] - 1] = true;
      ans++;
    } else if (!seen[a[i]]) {
      seen[a[i]] = true;
      ans++;
    } else if (!seen[a[i] + 1]) {
      seen[a[i] + 1] = true;
      ans++;
    }
  }
  std::cout << ans << '\n';
  return 0;
}
