func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T1, typename T2>   istream& operator>>(istream& in, pair<T1, T2>& a) {     in >> a.first >> a.second;     return in;   }   template <typename T1, typename T2>   ostream& operator<<(ostream& out, pair<T1, T2> a) {     out << a.first <<     << a.second;     return out;   }   template <typename T, typename T1>   T maxs(T& a, T1 b) {     if (b > a) a = b;     return a;   }   template <typename T, typename T1>   T mins(T& a, T1 b) {     if (b < a) a = b;     return a;   }   const long long N = (1 << 21);   const long long M = N - 1;   pair<long long, long long> dp[N];   long long solve() {     long long n;     cin >> n;     vector<long long> a(n + 1);     auto add = [&](long long mask, long long j) {       if (dp[mask].first == -1)         dp[mask].first = j;       else if (dp[mask].second == -1) {         dp[mask].second = j;         if (dp[mask].second < dp[mask].first)           swap(dp[mask].first, dp[mask].second);       } else if (dp[mask].second < j) {         dp[mask].first = dp[mask].second;         dp[mask].second = j;       } else if (dp[mask].first < j && j != dp[mask].second) {         dp[mask].first = j;       }     };     for (long long i = 1; i < n + 1; i++) {       cin >> a[i];       add(a[i], i);     }     for (long long i = 0; i < 21; i++) {       for (long long mask = 0; mask < N; mask++) {         if ((mask) & (1 << i)) {           if (dp[mask].first != -1) add(mask ^ (1 << i), dp[mask].first);           if (dp[mask].second != -1) add(mask ^ (1 << i), dp[mask].second);         }       }     }     long long ans = 0;     for (long long i = 1; i < n + 1; i++) {       long long rev_mask = M - a[i];       long long best = 0;       for (long long j = 20; j >= 0; j--) {         if (rev_mask & (1 << j)) {           if (dp[best ^ (1 << j)].second != -1 && dp[best ^ (1 << j)].first > i) {             best ^= (1 << j);           }         }       }       if (i + 2 <= n) maxs(ans, a[i] + best);     }     cout << ans <<   n ;     return 0;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) {       solve();     }     return 0;   }   