func_code_string: #include <bits/stdc++.h>   using namespace std;   struct debugger {     template <typename T>     debugger& operator,(const T& v) {       cerr << v <<    ;       return *this;     }   } debug1;   template <typename T1, typename T2>   inline ostream& operator<<(ostream& os, const pair<T1, T2>& p) {     return os <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <typename T>   inline ostream& operator<<(ostream& os, const vector<T>& v) {     bool first = true;     os <<  [ ;     for (typename vector<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii) {       if (!first) os <<  ,  ;       os << *ii;       first = false;     }     return os <<  ] ;   }   const long long inf = numeric_limits<long long>::min();   const int NN = 112345;   long long dp[NN][3], cnt[NN];   bool vis[NN][3];   long long f(int x, int last) {     last = ((cnt[x - 1] == 0 and last == 0) ? 2 : last);     if (cnt[x] == 0 and last == 0) return inf;     if (x > 100000) return 0LL;     if (vis[x][last]) return dp[x][last];     vis[x][last] = true;     long long ans = 0;     if (last == 0) {       ans = cnt[x] * (long long)x;       ans += f(x + 1, 1);     } else if (last == 1)       ans = f(x + 1, 2);     else {       ans = max(ans, f(x + 1, 0));       if (cnt[x] > 0) {         long long add = cnt[x] * (long long)x;         ans = max(ans, add + f(x + 1, 1));       }     }     dp[x][last] = ans;     return ans;   }   void solve() {     int n, num;     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> num;       cnt[num]++;     }     long long ans = f(1, 2);     cout << ans <<   n ;   }   int main() {     solve();     return 0;   }   