CCCPaste

Untitled

#include 
#include 
#include 
#include 
#include 
using namespace std;
typedef long long ll;
    
int main()
{
    int n;
    cin >> n;
    
    ll 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;
}
// 2222222222
// 22222222222