func_code_string: #include <bits/stdc++.h>   using namespace std;   int read() {     int x = 0, f = 0;     char ch = getchar();     while (!isdigit(ch)) f |= ch ==  - , ch = getchar();     while (isdigit(ch)) x = 10 * x + ch -  0 , ch = getchar();     return f ? -x : x;   }   template <typename T>   void print(T x) {     if (x < 0) putchar( - ), x = -x;     if (x >= 10) print(x / 10);     putchar(x % 10 +  0 );   }   template <typename T>   void print(T x, char let) {     print(x), putchar(let);   }   const int maxn = 2e5 + 5;   const int mn = (1 << 18) - 1;   int n, a[maxn], b[mn], f[mn], sz[mn];   int find(int k) {     if (f[k] == k) return k;     return f[k] = find(f[k]);   }   void merge(int a, int b) {     int fa = find(a);     int fb = find(b);     if (sz[fa] <= sz[fb]) {       f[fa] = fb;       sz[fb] += sz[fa];     } else {       f[fb] = fa;       sz[fa] += sz[fb];     }   }   int main() {     n = read();     long long sum1 = 0;     for (int i = 1; i <= n; i++) {       a[i] = read();       sum1 += a[i];       b[a[i]]++;     }     b[0]++;     for (int i = 0; i <= mn; i++) f[i] = i;     long long sum = 0;     for (int i = mn; i >= 1; i--) {       if (b[0] > 0 && b[i] > 0 && find(0) != find(i)) {         merge(0, i);         sum += (long long)(b[0] + b[i] - 1) * i;         b[0] = b[i] = 1;       }       for (int j = i; j; j = (j - 1) & i) {         int k = i ^ j;         if (b[j] > 0 && b[k] > 0 && find(j) != find(k)) {           merge(j, k);           sum += (long long)(b[j] + b[k] - 1) * i;           b[j] = b[k] = 1;         }       }     }     cout << sum - sum1 << endl;     return 0;   }   