#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef complex<ld> cld;
#define all(x) (x).begin(),(x).end()
#define len(x) ((ll) (x).size())
#define F first
#define S second
#define X real()
#define Y imag()
#define pb push_back
#define sep ' '
#define endl '\n'
#define Mp make_pair
#define kill(x) cout << x << '\n', exit(0)
#define set_dec(x) cout << fixed << setprecision(x);
#define file_io(x,y) freopen(x, "r", stdin); freopen(y, "w", stdout);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = (1 << 20) + 4;
int n; ll A[maxn];
int L[maxn], R[maxn];
priority_queue<pll> qu;
int mark[maxn];
void solve() {
cin >> n;
for (int i = 0; i < n; i++) cin >> A[i];
for (int i = 0; i < n; i++) {
L[i] = i - 1; R[i] = i + 1;
qu.push(Mp(A[i], i)); mark[i] = 1;
}
ll ans = 0;
for (int T = 0; T < (n + 1) / 2; T++) {
while (!qu.empty()) {
auto f = qu.top();
if (!mark[f.S]) qu.pop();
else break;
}
auto f = qu.top(); qu.pop();
ans += f.F; ll Rx = -f.F; int j = f.S;
if (L[j] != -1) {
Rx += A[L[j]];
mark[L[j]] = 0;
if (L[L[j]] != -1) {
R[L[L[j]]] = j; L[j] = L[L[j]];
}
}
if (R[j] != n) {
Rx += A[R[j]];
mark[R[j]] = 0;
if (R[R[j]] != n) {
L[R[R[j]]] = j; R[j] = R[R[j]];
}
}
A[j] = Rx; qu.push(Mp(A[j], j));
cout << ans << endl;
}
}
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int T = 1;
while (T--) {
solve();
}
return 0;
}