#include<bits/stdc++.h>
using namespace std;

void createTree(const vector<int> &arr, int pleft, int pright, int vleft, int vright, vector<int> &ans);

int main(void) {
    vector<int> arr;
    int n, t;

    while(cin >> t) { arr.push_back(t); }
    n = arr.size()/2;
    vector<int> ans(n, 0);
    createTree(arr, 0, n-1, n, 2*n-1, ans);

    for(int i = 0; i < n; i++) {
        if(i == 0) cout << ans[i];
        else cout << " " << ans[i]; 
    }
    return 0;
}
void createTree(const vector<int> &arr, int pleft, int pright, int vleft, int vright, vector<int> &ans) {
    if(pleft >= pright || vleft >= vright) return;

    int leftNum = 0, sum = 0;
    // 累加目前的中序遍历中所有的元素和,根节点要排除。
    for(int i = vleft; i <= vright; i++) {
        sum += arr[i];
        // 排除根节点,并记录左子树的孩子节点个数
        if(arr[i] == arr[pleft]) {
            sum -= arr[i];
            leftNum = i - vleft;
        }
    }
    // 当前中序的节点求和赋值
    ans[vleft + leftNum - ans.size()] = sum;
    // 依次遍历左子树和右子树
    createTree(arr, pleft+1, pleft+leftNum, vleft, vleft+leftNum-1, ans);
    createTree(arr, pleft+leftNum+1, pright, vleft+leftNum+1, vright, ans);
}