#include<bits/stdc++.h>
using namespace std;
#define Study ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ff first
#define ss second
#define ins insert
#define all(x) x.begin(),x.end()
#define fori(x,y,z) for(ll x=y;x<=z;x++)
const ll INF=1e9;
const ll sz=2e5+10;
const ll mod=1e9+7;
void work(){
ll n;
cin>>n;
vector<ll>d(n+10);
ll sum=0;
ll maximum=0;
bool have=0;
fori(i,1,n-1){
ll a;
cin>>a;
sum+=a;
d[i]=sum;
if(a==0)
have=1;
maximum=max(maximum,d[i]);
}
vector<ll>ans;
if(have==1){
cout<<-1;
return;
}
// cout<<maximum<<endl;
ll s=n-maximum;
if(s<=0){
have|=1;
}
ans.pb(s);
fori(i,1,n-1){
//cout<<d[i]<<" ";
ans.pb(d[i]+s);
if(d[i]+s<=0)
have=1;
}
if(have==1){
cout<<-1;
return;
}
fori(i,0,n-1)
cout<<ans[i]<<' ';
cout<<endl;
}
int main(){
Study;
ll t=1;
//cin>>t;
while(t--){
work();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |