#include <bits/stdc++.h>
using std::cout;
using namespace std;
int status[200002];
priority_queue<int> wei;
int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  int n;
  cin >> n;
  int lister;
  for (int i = 0; i < n; i++) {
    cin >> lister;
    if (status[lister] == 0) {
      wei.push(lister);
    }
  }
  while (!wei.empty()) {
    int tp = wei.top();
    if (status[tp + 1] == 0) {
      status[tp + 1] = 1;
    } else if (status[tp] == 0) {
      status[tp] = 1;
    } else if (status[tp - 1] == 0) {
      status[tp - 1] = 1;
    }
    wei.pop();
  }
  int res = 0;
  for (int i = 1; i < 150002; i++) {
    if (status[i] > 0) {
      res++;
    }
  }
  cout << res << endl;
}
