#include #include #include #include #include #include #include using namespace std; int main() { int n; cin >> n; long long add = 0, subtract = 0; for(int i = 1; i <= n; i++) { int x; cin >> x; int rounds = n; while(rounds > 1) { if(i <= rounds / 2) { add += x; } else if(i > rounds / 2 and i <= rounds) { subtract += x; } rounds /= 2; } } cout << add - subtract << endl; return 0; }