#include <bits/stdc++.h>   using namespace std;   int arr[111];   int main() {     int n;     scanf( %d , &n);     arr[0] = 0;     for (int i = (1); i < (n + 1); ++i) scanf( %d , &arr[i]);     int ans = 0;     if (n % 2 == 0 || n == 1) {       printf( -1 n );       return 0;     }     for (int i = n; i >= 1; i -= 2) {       int tmp = max(arr[i], arr[i - 1]);       ans += tmp;       arr[i] = arr[i - 1] = 0;       arr[(i - 1) / 2] = max(0, arr[(i - 1) / 2] - tmp);     }     printf( %d n , ans);     return 0;   }   