#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned int n;
  cin >> n;
  vector<unsigned int> ar(n);
  for (int i = 0; i < n; i++) cin >> ar[i];
  sort(ar.begin(), ar.end());
  int i = 0;
  int ans = 0;
  while (i < n) {
    int j = i;
    while (i + 1 < n && ar[i] == ar[i + 1]) {
      i++;
    }
    if (i - j + 1 == 1) {
      if ((j - 1 >= 0 && ar[j - 1] < ar[j] - 1) || (j == 0 && ar[j] > 1))
        ar[j]--;
      else if (i - 1 >= 0 && ar[i - 1] == ar[i])
        ar[i]++;
      ans += 1;
    } else if (i - j + 1 == 2) {
      if ((j - 1 >= 0 && ar[j - 1] < ar[j] - 1) || (j == 0 && ar[j] > 1)) {
        ar[j]--;
        ans += 2;
      } else if (j - 1 >= 0 && ar[j - 1] == ar[j]) {
        ar[i]++;
        ans += 1;
      } else {
        ar[i]++;
        ans += 2;
      }
    } else {
      ar[i]++;
      if ((j - 1 >= 0 && ar[j - 1] < ar[j] - 1) || (j == 0 && ar[j] > 1)) {
        ar[j]--;
        ans += 3;
      } else if ((j - 1 >= 0 && ar[j - 1] == ar[j])) {
        ans += 1;
      } else {
        ans += 2;
      }
    }
    i++;
  }
  cout << ans << endl;
  return 0;
}
