func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int trn = 1 << (n + 1);     trn--;     int a[30000];     for (int i = 2; i <= trn; i++) cin >> a[i];     int q = 1 << n;     int mx = 0;     int leng[30000];     for (int i = q; i <= trn; i++) {       leng[i] = 0;       int j = i;       while (j > 0) {         leng[i] += a[j];         j /= 2;       }       mx = max(mx, leng[i]);     }     int add[30000];     for (int i = q; i <= trn; i++) add[i] = mx - leng[i];     for (int depth = n + 1; depth > 1; depth--) {       q = 1 << (depth - 1);       for (int i = q; i < q * 2; i += 2) {         if ((add[i] > 0) && (add[i + 1] > 0)) {           int t = min(add[i], add[i + 1]);           add[i / 2] = t;           add[i] = add[i] - t;           add[i + 1] = add[i + 1] - t;         }       }     }     int ans = 0;     for (int i = 0; i <= trn; i++) ans += add[i];     cout << ans;   }   