#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e2 + 5;
int main()
{
int n;
cin >> n;
vector<long long> v(n);
for(int i = 0 ; i < n ; i++)
{
cin >> v[i];
}
if(n == 1)
{
cout << v[0] ;
return 0;
}
long long last = v.back();
vector<long long> ans;
for(int i = n - 2 ; i >= 1 ; i--)
{
if(v[i] + last <= v[i])
{
last+=v[i];
}
else
{
ans.push_back(last);
last = v[i];
}
}
if(v[0] + last <= v[0])
ans.push_back(v[0] + last);
else
{
ans.push_back(last);
ans.push_back(v[0]);
}
while(ans.size())
{
cout << ans.back() << ' ';
ans.pop_back();
}
}
Copy