#include <bits/stdc++.h>
using namespace std;
const int maxn = 150000 + 100;
int a[maxn];
int vis[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    vis[a[i]]++;
  }
  for (int i = 1; i <= 150001; ++i) {
    if (!vis[i]) continue;
    if (i - 1 > 0 && vis[i - 1] == 0) {
      vis[i - 1]++;
      vis[i]--;
    }
    if (vis[i] >= 2 && i + 1 <= 150001) {
      vis[i + 1]++;
      vis[i]--;
    }
  }
  int ans = 0;
  for (int i = 1; i <= 150001; ++i)
    if (vis[i]) ans++;
  cout << ans;
  return 0;
}
