#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 123, inf = 1e9 + 123, mod = 1e9 + 7;   const long long INF = 1e18;   int n, a[N];   int main() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(0);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     sort(a + 1, a + n + 1);     reverse(a + 1, a + n + 1);     int mn = inf;     for (int i = 1; i <= n; i++) {       if (a[i] + 1 < mn) {         a[i]++;         mn = a[i];       } else {         if (a[i] < mn) {           mn = a[i];         } else if (a[i] - 1 < mn && a[i] > 1) {           mn = a[i] - 1;           a[i]--;         }       }     }     set<int> st;     for (int i = 1; i <= n; i++) {       st.insert(a[i]);     }     cout << st.size();     return 0;   }   