#include <bits/stdc++.h>
using nt = unsigned int;
constexpr nt N = 150000;
template <typename T>
using ContType = std::set<T>;
int main() {
  nt arr[N];
  nt n, v;
  std::cin >> n;
  for (nt i = 0; i < n; ++i) {
    std::cin >> arr[i];
  }
  std::sort(arr, arr + n);
  std::unordered_set<nt> used;
  arr[0] = arr[0] == 1 ? 1 : arr[0] - 1;
  used.insert(arr[0]);
  for (nt i = 1; i < n; ++i) {
    if (used.find(arr[i] - 1) == std::end(used) && arr[i] != 1) {
      used.insert(arr[i] - 1);
    } else if (used.find(arr[i]) == std::end(used)) {
      used.insert(arr[i]);
    } else if (used.find(arr[i] + 1) == std::end(used)) {
      used.insert(arr[i] + 1);
    }
  }
  std::cout << used.size();
  return 0;
}
