#include <bits/stdc++.h>
using namespace std;
bool isvowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' ||
      c == 'E' || c == 'I' || c == 'O' || c == 'U')
    return true;
  return false;
}
bool prime[1000001];
int spf[1000001];
vector<int> primes;
void sieve() {
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= 1000000; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= 1000000; i += p) {
        prime[i] = false;
        spf[i] = p;
      }
    }
  }
  for (int p = 2; p <= 1000000; p++)
    if (prime[p]) primes.push_back(p);
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int fast_exp(long long int x, long long int n) {
  long long int ans = 1;
  while (n) {
    if (n & 1) ans *= x;
    n = n >> 1;
    x = x * x;
  }
  return ans;
}
long long int mod_exp(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n;
  cin >> n;
  long long int a[n];
  map<long long int, int> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 1) {
      if (m[a[i]] < 2) m[a[i]]++;
    } else {
      if (m[a[i]] < 3) m[a[i]]++;
    }
  }
  {}
  set<long long int> s;
  for (auto it = m.begin(); it != m.end(); it++) {
    long long int x = it->first;
    if (x == 1) {
      s.insert(1);
      if (it->second > 1) {
        s.insert(2);
      }
    } else {
      if (it->second == 1) {
        if (s.find(x - 1) == s.end())
          s.insert(x - 1);
        else if (s.find(x) == s.end())
          s.insert(x);
        else if (s.find(x + 1) == s.end())
          s.insert(x + 1);
      }
      if (it->second == 2) {
        if (s.find(x - 1) == s.end()) {
          s.insert(x - 1);
          if (s.find(x) == s.end())
            s.insert(x);
          else
            s.insert(x + 1);
        } else {
          s.insert(x);
          s.insert(x + 1);
        }
      } else if (it->second == 3) {
        s.insert(x);
        s.insert(x - 1);
        s.insert(x + 1);
      }
    }
  }
  cout << s.size();
}
