func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   int a[4000];   int ans[4000][4000];   int main() {     cin >> n;     map<int, int> r;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (r.find(a[i]) == r.end()) {         int k = r.size();         r[a[i]] = k;       }       a[i] = r[a[i]];     }     int m = r.size();     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (ans[j][a[i]] + 1 > ans[a[i]][j]) {           ans[a[i]][j] = ans[j][a[i]] + 1;         }       }     }     int best = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (ans[i][j] > best) {           best = ans[i][j];         }       }     }     cout << best << endl;     return 0;   }   