#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> H(N + 1);
    for (int i = 1; i <= N; ++i)
        cin >> H[i];
    stack<pair<int, int>> st;
    int ans = 0;
    int prev = 0;
    st.push(make_pair(1000000010, 0));
    for (int i = 1; i <= N; ++i)
    {
        while (st.top().first <= H[i])
        {
            if (st.top().second % 2 == 0)
                ans += st.top().first;
            else
                ans -= st.top().first;
            st.pop();
        }
        if (st.top().second % 2 != i % 2)
        {
            if (i % 2 == 1)
                ans += H[i];
            else
                ans -= H[i];
        }
        st.push(make_pair(H[i], i));
        cout << ans << endl;
    }
    return 0;
}