func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   inline void getar(T a, int n, int m) {     for (int i = 0; i < n; i++)       for (int j = 0; j < m; ++j) {         scanf( %d , &a[i][j]);       }   }   inline void getar(int *a, int n) {     for (int ii = 0; ii < n; ii++) {       scanf( %d , a + ii);     }   }   inline void getar(pair<int, int> *a, int n) {     for (int ii = 0; ii < n; ii++) {       scanf( d , &a[ii].first, &a[ii].second);     }   }   inline void getar(long long *a, int n) {     for (int ii = 0; ii < n; ii++) {       scanf( %I64d , a + ii);     }   }   inline void getv(vector<int> &a, int n) {     for (int ii = 0; ii < n; ii++) {       scanf( %d , &a[ii]);     }   }   inline void getv(vector<long long> &a, int n) {     for (int ii = 0; ii < n; ii++) {       scanf( %I64d , &a[ii]);     }   }   inline void getv(vector<pair<int, int> > &a, int n) {     for (int ii = 0; ii < n; ii++) {       scanf( %d , &a[ii].first, &a[ii].second);     }   }   inline void getv(vector<pair<long long, long long> > &a, int n) {     for (int ii = 0; ii < n; ii++) {       scanf( %I64d , &a[ii].first, &a[ii].second);     }   }   inline void getvv(vector<vector<int> > &a, int n, int m) {     for (int i = 0; i < n; i++)       for (int j = 0; j < m; ++j) {         scanf( %d , &a[i][j]);       }   }   inline void printa(int *a, int i, int j) {     for (int ii = i; ii <= j; ii++) {       printf( %d  , a[ii]);     }   }   inline void printa(long long *a, int i, int j) {     for (int ii = i; ii <= j; ii++) {       printf( %I64d  , a[ii]);     }   }   inline void printv(vector<int> &a, int i, int j) {     for (int ii = i; ii <= j; ii++) {       printf( %d  , a[ii]);     }   }   inline void printv(vector<long long> &a, int n, int i, int j) {     for (int ii = i; ii <= j; ii++) {       printf( %I64d  , a[ii]);     }   }   inline long long max(long long a, long long b) { return (a > b) ? a : b; }   inline int max(int a, int b) { return (a > b) ? a : b; }   inline double max(double a, double b) { return (a > b) ? a : b; }   inline long long max(long long a, long long b, long long c) {     return max(a, max(b, c));   }   inline int max(int a, int b, int c) { return max(a, max(b, c)); }   inline double max(double a, double b, double c) { return max(a, max(b, c)); }   inline long long min(long long a, long long b) { return (a < b) ? a : b; }   inline int min(int a, int b) { return (a < b) ? a : b; }   inline double min(double a, double b) { return (a < b) ? a : b; }   inline long long min(long long a, long long b, long long c) {     return min(a, min(b, c));   }   inline int min(int a, int b, int c) { return min(a, min(b, c)); }   inline double min(double a, double b, double c) { return min(a, min(b, c)); }   inline long long pow(long long x, long long n) {     long long res = 1;     while (n) {       if (n & 1) res *= x;       x *= x;       n >>= 1;     }     return res;   }   inline long long powmod(long long x, long long n, long long _mod) {     long long res = 1;     while (n) {       if (n & 1) res = (res * x) % _mod;       x = (x * x) % _mod;       n >>= 1;     }     return res;   }   inline long long gcd(long long a, long long b) {     long long t;     while (b) {       a = a % b;       t = a;       a = b;       b = t;     }     return a;   }   inline int gcd(int a, int b) {     int t;     while (b) {       a = a % b;       t = a;       a = b;       b = t;     }     return a;   }   inline long long lcm(int a, int b) { return a / gcd(a, b) * (long long)b; }   inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   inline long long gcd(long long a, long long b, long long c) {     return gcd(gcd(a, b), c);   }   inline int gcd(int a, int b, int c) { return gcd(gcd(a, b), c); }   inline long long lcm(long long a, long long b, long long c) {     return lcm(lcm(a, b), c);   }   inline long long lcm(int a, int b, int c) {     return lcm(lcm(a, b), (long long)c);   }   inline int bits_count(int v) {     v = v - ((v >> 1) & 0x55555555);     v = (v & 0x33333333) + ((v >> 2) & 0x33333333);     return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;   }   inline int bits_count(long long v) {     long long t = v >> 32;     long long p = (v & ((1LL << 32) - 1));     return bits_count(t) + bits_count(p);   }   inline bool ispow2(int x) { return (x != 0 && (x & (x - 1)) == 0); }   const char nl =   n ;   void solve() {     int n;     cin >> n;     vector<int> a(n);     getv(a, n);     int last = -1, cnt = 0;     sort(a.begin(), a.end());     for (int i = 0; i < n; i++) {       if (a[i] != 1 && last < a[i] - 1)         last = a[i] - 1, cnt++;       else if (last < a[i])         last = a[i], cnt++;       else if (last < a[i] + 1)         last = a[i] + 1, cnt++;     }     cout << cnt << nl;   }   int main() {     clock_t clk = clock();     cerr <<  Hey P.. n ;     int t;     t = 1;     while (t--) solve();     cerr <<  Look at the sky. n ;     cerr <<  Time (in ms):   << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC          <<   n ;     return 0;   }   