#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, ll> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }

int n;
int a[200009];
pii memo[200009][2];
int seen[200009][2];
const int ok = 0, imp = 1, a1 = 2;
pii solve(int i, bool on2) {
	if(i < 0 || i >= n) return pii(ok, 0);
	if(i == 0 && on2) return pii(imp, 0);
	if(i == 0) return pii(a1, 0);
	pii &r = memo[i][on2];
	if(seen[i][on2] == 2) return r;
	if(seen[i][on2] == 1) return r = pii(imp, 0);
	seen[i][on2] = 1;
	pii x = solve(i + a[i] * (on2 * 2 - 1), !on2);
	r = x;
	if(r.fst != imp)
		r.snd += a[i];
	seen[i][on2] = 2;
	return r;
}

int main() {

    /// Skip this ladder problem ! - msh fahmha

	int i;
	scanf("%d", &n);
	for(i = 1; i < n; i++)
		scanf("%d", &a[i]);
	for(i = 0; i < n - 1; i++) {
		pii y = solve(i + 1, false);
		y.snd += i + 1;
		if(y.fst == a1) y.snd += i + 1;
		if(y.fst == imp) puts("-1");
		else printf("%I64d\n", y.snd);
	}

}


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

#define all(x)		x.begin(),x.end()
#define sz(x)		(int)x.size()
#define ll			long long
#define popCnt(x)   __builtin_popcount(x)

int n;
int arr[200200];
long long dp[200200];

ll solve(int cur){
	if(cur<=1||cur>n)return (cur==1?(-1*1LL<<50):0);
	if(dp[cur]==0) return (-1*1LL<<50);
	if(dp[cur]!=-1)return dp[cur];
	dp[cur]=0;
	int tmp=cur,val=0;
	val+=arr[cur];
	tmp+=arr[cur];
	if(tmp<=n){
		val+=arr[tmp];
		tmp-=arr[tmp];
		return dp[cur]=solve(tmp)+val;
	}
	return dp[cur]=val;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);
#endif
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
		scanf("%d",&arr[i]);
	memset(dp,-1,sizeof dp);
	dp[1]=0;
	for(int i=2;i<=n;i++){
		if(dp[i]==-1){
			dp[i]=solve(i);
			if(dp[i]<-1)dp[i]=0;
			continue;
		}
		if(dp[i]<-1)dp[i]=0;
	}
	for(int i=1;i<n;i++){
		int x=1,y=0;
		y+=i;
		x+=i;
		y+=arr[x];
		x-=arr[x];
		if(x<1){
			printf("%d\n",y);
			continue;
		}
		if(dp[x]==0){
			puts("-1");
			continue;
		}
		printf("%lld\n",y+dp[x]);
	}
}


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

#define all(x)		x.begin(),x.end()
#define sz(x)		(int)x.size()
#define ll			long long
#define popCnt(x)   __builtin_popcount(x)

int n,x,y;
int arr[200200];
ll dp[200200];

ll solve(int i){
	if(i<1||i>n)return 0;
	ll &ret=dp[i];
	if(~ret)return ret;
	ret=-1e15;
	int val=0,cur=i;
	val+=arr[cur],cur+=arr[cur];
	if(cur>n)return ret=val;
	val+=arr[cur],cur-=arr[cur];
	return ret=val+solve(cur);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);
#endif
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
		scanf("%d",&arr[i]);
	memset(dp,-1,sizeof dp);
	dp[1]=-1e15;
	for(int i=2;i<=n;i++)
		if(dp[i]==-1)dp[i]=solve(i);
	dp[0]=-1;
	for(int i=1;i<n;i++){
		y=i,x=i+1;
		y+=arr[x],x-=arr[x];
		printf("%lld\n",(x<1?y:(dp[x]<0?-1:dp[x]+y)));
	}
}


#include <bits/stdc++.h>

using namespace std;

#define NMAX 200010

int A[NMAX];
int n;

long long Y2[NMAX], Y3[NMAX];

long long y2(int x);

long long y3(int x) {
  if (x <= 0 || x > n) {
    return 0;
  }
  if (x == 1) {
    return -1;
  }
  if (Y3[x] != -2) {
    return Y3[x];
  }
  long long rec = y2(x - A[x]);
  if (rec == -1) {
    return Y3[x] = rec;
  }
  return Y3[x] = A[x] + rec;
}

long long y2(int x) {
  if (x <= 0 || x > n) {
    return 0;
  }
  if (x == 1) {
    return -1;
  }
  if (Y2[x] != -2) {
    return Y2[x];
  }
  long long rec = y3(x + A[x]);
  if (rec == -1) {
    return Y2[x] = rec;
  }
  return Y2[x] = A[x] + rec;
}

int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &A[i]);
  }
  for (int i = 0; i <= n; i++) {
    Y2[i] = Y3[i] = -2;
  }
  for (int a1 = 1; a1 < n; a1++) {
    long long out = y3(1 + a1);
    printf("%I64d\n", out == -1 ? -1 : out + a1);
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define NMAX 200010

int A[NMAX];
long long Y2[NMAX], Y3[NMAX];
int n;

long long y2(int x);

long long y3(int x) {
  if (x <= 0 || x > n) {
    return 0;
  }
  if (x == 1) {
    return -1;
  }
  if (Y3[x] != -2) {
    return Y3[x];
  }
  Y3[x] = -1;
  long long rec = y2(x - A[x]);
  if (rec == -1) {
    return Y3[x] = rec;
  }
  return Y3[x] = A[x] + rec;
}

long long y2(int x) {
  if (x <= 0 || x > n) {
    return 0;
  }
  if (x == 1) {
    return -1;
  }
  if (Y2[x] != -2) {
    return Y2[x];
  }
  Y2[x] = -1;
  long long rec = y3(x + A[x]);
  if (rec == -1) {
    return Y2[x] = rec;
  }
  return Y2[x] = A[x] + rec;
}

/*
int P[NMAX];

long long f(int a1) {
  int ps = 0;

  P[ps++] = 1 + a1;
  long long *Y = Y3;

  while (ps) {
    int x = P[--ps];
    if (x <= 0 || x > n) {
      // return 0
    }
    if (x == 1) {
      // return 1
    }
    if (Y[x] != -2) {
      // return Y[x]
    }

    if (Y == Y2) {
      P[ps++] = x + A[x];
      Y = Y3;
    } else {
      P[ps++] = x - A[x];
      Y = Y2;
    }
  }
}
*/

int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &A[i]);
  }
  for (int i = 0; i <= n; i++) {
    Y2[i] = Y3[i] = -2;
  }
  for (int a1 = 1; a1 < n; a1++) {
    long long out = y3(1 + a1);
    printf("%I64d\n", out == -1 ? -1 : out + a1);
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=2e5+9;
const ll mod=1e9+7;
ll n,a[MX],dp[MX][3];
bool vis[MX][3];
ll DP(ll x,ll y){
    if(x<=0||x>n)return 0;
    ll &ret=dp[x][y];if(ret!=-2)return ret;
    ret=-1;
    ll x1;
    if(y==2){
        x1=DP(x+a[x],3);
        if(x1==-1)return -1;
        return ret=a[x]+x1;
    }
    x1=DP(x-a[x],2);
    if(x1==-1)return -1;
    return ret=a[x]+x1;
}
int main(){
    for(int i=0;i<MX;i++){
        for(int j=0;j<10;j++){
            dp[i][j]=-2;
        }
    }
    scanf("%lld",&n);
    for(int i=2;i<=n;i++)scanf("%lld",&a[i]);
    for(int i=1;i<n;i++){
        a[1]=i;
        dp[1][2]=-2;
        printf("%lld\n",DP(1,2));
    }
}


#define ll long long
#define mod 1000000007
#define f first
#define s second
#define MAXN   100001
#include <bits/stdc++.h>
using namespace std;
vector<ll> vis;
vector<vector<ll>> ans(200009,vector<ll>(2,0));
vector<ll> v;
ll n;
ll recur(ll index,ll f)
{
    if(index<=0 || index>n)
    {
        return 0;
    }
    else if(vis[index]==1 || ans[index][f%2]==-1)
    {
        return -1;
    }
    else if(ans[index][f%2]!=0)
    {
        return ans[index][f%2];
    }
    vis[index]=1;
    ll b;
    if(f%2==0)
    {
        b=index+v[index];
    }
    else
    {
        b=index-v[index];
    }

    ll a=recur(b,f+1);
    vis[index]=0;
    if(a==-1)
    {ans[index][f%2]=-1;
    return -1;
    }
    ans[index][f%2]=v[index]+a;
    return v[index]+a;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    cin>>n;
    v.resize(n+1);
    vis.resize(n+1);
    // ans.resize(n+1);
    for(ll i=2;i<=n;i++)
    {
        cin>>v[i];
        vis[i]=0;
    }
    vis[1]=1;
    ans[1][0]=-1;
    ans[1][1]=-1;
    for(ll i=1;i<n;i++)
    {
        v[1]=i;
        ll a=recur(i+1,1);
        if(a==-1)
        cout<<-1<<endl;
        else
        {
            cout<<a+i<<endl;
        }

    }
        return 0;

}


#define ll long long
#define mod 1000000007
#define f first
#define s second
#define MAXN   100001
#include <bits/stdc++.h>
using namespace std;
vector<ll> vis;
vector<ll> ans;
vector<ll> v;
ll n;
ll recur(ll index,ll f)
{
    if(index<=0 || index>n)
    {
        return 0;
    }
    else if(vis[index]==1)
    {
        if(ans[index]==-1)
        return -1;
        else
        {
            return ans[index];
        }

    }
    vis[index]=1;
    ll b;
    if(f%2==0)
    {
        b=index+v[index];
    }
    else
    {
        b=index-v[index];
    }
    f++;
    ll a=recur(b,f);
    if(a==-1)
    {ans[index]=-1;
    return -1;
    }
    ans[index]=v[index]+a;
    return v[index]+a;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    cin>>n;
    v.resize(n+1);
    vis.resize(n+1);
    ans.resize(n+1);
    for(ll i=2;i<=n;i++)
    {
        cin>>v[i];
        vis[i]=0;
    }
    vis[1]=1;
    ans[1]=-1;
    for(ll i=1;i<n;i++)
    {
        v[1]=i;
        ll a=recur(i+1,1);
        if(a==-1)
        cout<<-1<<endl;
        else
        {
            cout<<a+i<<endl;
        }

    }
        return 0;

}


#define ll long long
#define mod 1000000007
#define f first
#define s second
#define MAXN   100001
#include <bits/stdc++.h>
using namespace std;
vector<ll> vis;
vector<vector<ll>> ans(100000,vector<ll>(2,0));
vector<ll> v;
ll n;
ll recur(ll index,ll f)
{
    if(index<=0 || index>n)
    {
        return 0;
    }
    else if(vis[index]==1 || ans[index][f%2]==-1)
    {
        return -1;
    }
    else if(ans[index][f%2]!=0)
    {
        return v[index]+ans[index][f%2];
    }
    vis[index]=1;
    ll b;
    if(f%2==0)
    {
        b=index+v[index];
    }
    else
    {
        b=index-v[index];
    }

    ll a=recur(b,f+1);
    vis[index]=0;
    if(a==-1)
    {ans[index][f%2]=-1;
    return -1;
    }
    ans[index][f%2]=v[index]+a;
    return v[index]+a;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    cin>>n;
    v.resize(n+1);
    vis.resize(n+1);
    // ans.resize(n+1);
    for(ll i=2;i<=n;i++)
    {
        cin>>v[i];
        vis[i]=0;
    }
    vis[1]=1;
    ans[1][0]=-1;
    ans[1][1]=-1;
    for(ll i=1;i<n;i++)
    {
        v[1]=i;
        ll a=recur(i+1,1);
        if(a==-1)
        cout<<-1<<endl;
        else
        {
            cout<<a+i<<endl;
        }

    }
        return 0;

}


#define ll long long
#define mod 1000000007
#define f first
#define s second
#define MAXN   100001
#include <bits/stdc++.h>
using namespace std;
vector<vector<ll>> vis(200009,vector<ll>(2,0));
vector<vector<ll>> ans(200009,vector<ll>(2,0));
vector<ll> v;
ll n;
ll recur(ll index,ll f)
{
    if(index<=0 || index>n)
    {
        return 0;
    }
    else if(vis[index][f%2]==1 || ans[index][f%2]==-1)
    {
        return -1;
    }
    else if(ans[index][f%2]!=0)
    {
        return ans[index][f%2];
    }
    vis[index][f%2]=1;
    ll b;
    if(f%2==0)
    {
        b=index+v[index];
    }
    else
    {
        b=index-v[index];
    }

    ll a=recur(b,f+1);
    vis[index][f%2]=0;
    if(a==-1)
    {
        ans[index][f%2]=-1;
        return -1;
    }
    ans[index][f%2]=v[index]+a;
    return v[index]+a;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    cin>>n;
    v.resize(n+1);
    vis.resize(n+1);
    // ans.resize(n+1);
    for(ll i=2;i<=n;i++)
    {
        cin>>v[i];
        vis[i][0]=0;
        vis[i][1]=0;
    }
    vis[1][0]=1;
    ans[1][0]=-1;
    ans[1][1]=-1;
    for(ll i=1;i<n;i++)
    {
        v[1]=i;
        ll a=recur(i+1,1);
        if(a==-1)
            cout<<-1<<endl;
        else
        {
            cout<<a+i<<endl;
        }

    }
        return 0;

}


#define ll long long
#define mod 1000000007
#define f first
#define s second
#define MAXN   100001
#include <bits/stdc++.h>
using namespace std;
vector<ll> vis;
vector<vector<ll>> ans(200009,vector<ll>(2,0));
vector<ll> v;
ll n;
ll recur(ll index,ll f)
{
    if(index<=0 || index>n)
    {
        return 0;
    }
    else if(vis[index]==1)
    {
        return -1;
    }
    else if(ans[index][f%2]!=0)
    {
        return ans[index][f%2];
    }
    vis[index]=1;
    ll b;
    if(f%2==0)
    {
        b=index+v[index];
    }
    else
    {
        b=index-v[index];
    }

    ll a=recur(b,f+1);
    vis[index]=0;
    if(a==-1)
    {
    return -1;
    }
    ans[index][f%2]=v[index]+a;
    return v[index]+a;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    cin>>n;
    v.resize(n+1);
    vis.resize(n+1);
    // ans.resize(n+1);
    for(ll i=2;i<=n;i++)
    {
        cin>>v[i];
        vis[i]=0;
    }
    vis[1]=1;
    ans[1][0]=-1;
    ans[1][1]=-1;
    for(ll i=1;i<n;i++)
    {
        v[1]=i;
        ll a=recur(i+1,1);
        if(a==-1)
        cout<<-1<<endl;
        else
        {
            cout<<a+i<<endl;
        }

    }
        return 0;

}


#define ll long long
#define mod 1000000007
#define f first
#define s second
#define MAXN   100001
#include <bits/stdc++.h>
using namespace std;
vector<ll> vis;
vector<vector<ll>> ans(10000,vector<ll>(2,0));
vector<ll> v;
ll n;
ll recur(ll index,ll f)
{
    if(index<=0 || index>n)
    {
        return 0;
    }
    else if(vis[index]==1 || ans[index][f%2]==-1)
    {
        return -1;
    }
    else if(ans[index][f%2]!=0)
    {
        return ans[index][f%2];
    }
    vis[index]=1;
    ll b;
    if(f%2==0)
    {
        b=index+v[index];
    }
    else
    {
        b=index-v[index];
    }

    ll a=recur(b,f+1);
    vis[index]=0;
    if(a==-1)
    {ans[index][f%2]=-1;
    return -1;
    }
    ans[index][f%2]=v[index]+a;
    return v[index]+a;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    cin>>n;
    v.resize(n+1);
    vis.resize(n+1);
    // ans.resize(n+1);
    for(ll i=2;i<=n;i++)
    {
        cin>>v[i];
        vis[i]=0;
    }
    vis[1]=1;
    ans[1][0]=-1;
    ans[1][1]=-1;
    for(ll i=1;i<n;i++)
    {
        v[1]=i;
        ll a=recur(i+1,1);
        if(a==-1)
        cout<<-1<<endl;
        else
        {
            cout<<a+i<<endl;
        }

    }
        return 0;

}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define mem(a, v) memset(a, v, sizeof(a))
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> PII;
typedef vector<VI> matrix;
const ll mod = 1000000007LL;

ll dp[200200][2];
bool visited[200200][2];
ll arr[200200];
int n;

ll dfs(int u, bool flag)
{
    if(u > n || u < 1)
        return 0;
    if(visited[u][flag])
        return dp[u][flag];
    visited[u][flag] = true;
    ll ret = 0;
    if(flag){
        ret += dfs(u + arr[u], !flag);
    }
    else{
        ret += dfs(u - arr[u], !flag);
    }
    if(ret == -1)
        return dp[u][flag] = -1;
    return dp[u][flag] = arr[u] + ret;
}

int main()
{
    cin>>n;
    for(int i=2; i<=n; i++){
        cin>>arr[i];
    }
    mem(dp, -1);
    visited[1][0] = visited[1][1] = true;
    dp[1][0] = 0;
    for(int i=2; i<=n; i++){
        if(!visited[i][0])
           dfs(i, 0);
    }
    for(int i=1; i<n; i++){
        cout<<((dp[i+1][0] == -1)?-1:(dp[i+1][0] + i))<<"\n";
    }
    return 0;
}


/*
 * @Author: SugarSBN
 * @Date: 2018-07-14 13:10:05
 * @Language:   C++
 */
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<sstream>
#include<fstream>
using namespace std;
const int MAXN=1e5+11;
const double pi=acos(-1);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef double dbl;
#define For(a,b,c) for (int (a)=(b);(a)<(c);(a)++)
#define foreach(iter,V) for (__typeof((V.begin()) iter=(V).begin();iter!=(V).end();iter++)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
int n;
ll arr[MAXN*2];
ll x,y;
bool app[MAXN];
int main(){
    scanf("%d", &n);
    For(i,2,n+1)  {
        scanf("%I64d", arr + i);
    }
    For(i,1,n){
        arr[1] = i;
        x = 1 + i;
        y = i;
        memset(app, 0, sizeof(app));
        app[x] = 1;
        while(0<x&&x<=n){
            y += arr[x];
            x -= arr[x];
            if (x<=0||x>n)
                break;
            if (app[x]==1){
                y = -1;
                break;
            }
            app[x] = 1;
            y += arr[x];
            x += arr[x];
            if (x<=0||x>n)
                break;
            if (app[x]==1){
                y = -1;
                break;
            }
            app[x] = 1;
        }
        printf("%I64d\n", y);
    }
    return 0;
}


/*
 * @Author: SugarSBN
 * @Date: 2018-07-14 13:10:05
 * @Language:   C++
 */
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<sstream>
#include<fstream>
using namespace std;
const int MAXN=2e5+11;
const double pi=acos(-1);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef double dbl;
#define For(a,b,c) for (int (a)=(b);(a)<(c);(a)++)
#define foreach(iter,V) for (__typeof((V.begin()) iter=(V).begin();iter!=(V).end();iter++)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
int n;
ll arr[MAXN*2];
ll dp[MAXN][2];
bool vis[MAXN][2];
ll ans[MAXN];
ll dfs(ll x,int dire){
    if (x<=0||x>n)
        return 0;
    if (vis[x][dire])
        return dp[x][dire];
    vis[x][dire] = 1;
    if (dire==1)
        dp[x][dire] = arr[x] + dfs(x + arr[x], dire ^ 1);
    else
    {
        dp[x][dire] = arr[x] + dfs(x - arr[x], dire ^ 1);
    }
    return dp[x][dire];
}
int main(){
    //freopen("in.txt", "r", stdin);
    scanf("%d", &n);
    For(i,2,n+1)  {
        scanf("%I64d", arr + i);
    }
    For(i, 1, n + 1) dp[i][0] = dp[i][1] = 1e17;
    For(i,1,n){
        arr[1] = i;
        ans[i] = arr[1];
        ans[i] += dfs(1+i, 0);
    }
    For(i,1,n){
        if (ans[i]>=1e17)
            puts("-1");
        else{
            printf("%I64d\n", ans[i]);
        }
    }
    return 0;
}


/*
 * @Author: SugarSBN
 * @Date: 2018-07-14 13:10:05
 * @Language:   C++
 */
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<sstream>
#include<fstream>
using namespace std;
const int MAXN=2e5+11;
const double pi=acos(-1);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef double dbl;
#define For(a,b,c) for (int (a)=(b);(a)<(c);(a)++)
#define foreach(iter,V) for (__typeof((V.begin()) iter=(V).begin();iter!=(V).end();iter++)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
int n;
ll arr[MAXN*2];
ll x,y;
bool app[MAXN];
int main(){
    scanf("%d", &n);
    For(i,2,n+1)  {
        scanf("%I64d", arr + i);
    }
    For(i,1,n){
        arr[1] = i;
        x = 1 + i;
        y = i;
        memset(app, 0, sizeof(app));
        app[x] = 1;
        while(0<x&&x<=n){
            y += arr[x];
            x -= arr[x];
            if (x<=0||x>n)
                break;
            if (app[x]==1){
                y = -1;
                break;
            }
            app[x] = 1;
            y += arr[x];
            x += arr[x];
            if (x<=0||x>n)
                break;
            if (app[x]==1){
                y = -1;
                break;
            }
            app[x] = 1;
        }
        printf("%I64d\n", y);
    }
    return 0;
}


/*
 * @Author: SugarSBN
 * @Date: 2018-07-14 13:10:05
 * @Language:   C++
 */
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<sstream>
#include<fstream>
using namespace std;
const int MAXN=2e5+11;
const double pi=acos(-1);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef double dbl;
#define For(a,b,c) for (int (a)=(b);(a)<(c);(a)++)
#define foreach(iter,V) for (__typeof((V.begin()) iter=(V).begin();iter!=(V).end();iter++)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
int n;
ll arr[MAXN*2];
ll dp[MAXN][2];
bool vis[MAXN][2];
ll ans[MAXN];
int dfs(int x,int dire){
    if (x<=0||x>n)
        return 0;
    if (vis[x][dire])
        return dp[x][dire];
    vis[x][dire] = 1;
    if (dire==1)
        dp[x][dire] = arr[x] + dfs(x + arr[x], dire ^ 1);
    else
    {
        dp[x][dire] = arr[x] + dfs(x - arr[x], dire ^ 1);
    }
    return dp[x][dire];
}
int main(){
    //freopen("in.txt", "r", stdin);
    scanf("%d", &n);
    For(i,2,n+1)  {
        scanf("%I64d", arr + i);
    }
    For(i, 1, n + 1) dp[i][0] = dp[i][1] = MAXN - 1;
    For(i,1,n){
        arr[1] = i;
        ans[i] = arr[1];
        ans[i] += dfs(1+i, 0);
    }
    For(i,1,n){
        if (ans[i]>=MAXN-1)
            puts("-1");
        else{
            printf("%I64d\n", ans[i]);
        }
    }
    return 0;
}


/*
 * @Author: SugarSBN
 * @Date: 2018-07-14 13:10:05
 * @Language:   C++
 */
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<sstream>
#include<fstream>
using namespace std;
const int MAXN=1e5+11;
const double pi=acos(-1);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef double dbl;
#define For(a,b,c) for (int (a)=(b);(a)<(c);(a)++)
#define foreach(iter,V) for (__typeof((V.begin()) iter=(V).begin();iter!=(V).end();iter++)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
int n;
int arr[MAXN*2];
int x,y;
bool app[MAXN];
int main(){
    scanf("%d", &n);
    For(i,2,n+1)  {
        scanf("%d", arr + i);
    }
    For(i,1,n){
        arr[1] = i;
        x = 1 + i;
        y = i;
        memset(app, 0, sizeof(app));
        app[x] = 1;
        while(0<x&&x<=n){
            y += arr[x];
            x -= arr[x];
            if (x<=0||x>n)
                break;
            if (app[x]==1){
                y = -1;
                break;
            }
            app[x] = 1;
            y += arr[x];
            x += arr[x];
            if (x<=0||x>n)
                break;
            if (app[x]==1){
                y = -1;
                break;
            }
            app[x] = 1;
        }
        printf("%d\n", y);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
//-------
const int N = 2e5 + 7;
int n, a[N], ts;
int t[N][2];
ll v[N][2];
ll dfs(int x, int d) {
	if (x < 1 || x > n)
		return 0;
	if (x == 1 || t[x][d] == ts)
		return -1;
	if (!t[x][d]) {
		t[x][d] = ts;
		int nx = x + (d ? -a[x] : a[x]);
		ll nv = dfs(nx, d ^ 1);
		if (nv == -1)
			return -1;
		v[x][d] = nv + a[x];
	}
	return v[x][d];
}
int main() {
	scanf("%d", &n);
	rep(i, 2, n + 1)
		scanf("%d", &a[i]);
	ts = 0;
	rep(i, 1, n) {
		++ts;
		ll ans = dfs(1 + i, 1);
		printf("%lld\n", ans < 0 ? -1 : ans + i);
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
//-------head-------
const int N = 2e5 + 7;
int n, a[N], t[N];
ll v[N];
int main() {
	scanf("%d", &n);
	rep(i, 2, n + 1)
		scanf("%d", &a[i]);
	rep(i, 2, n + 1) {
		t[i] = i - a[i];
		if (t[i] <= 0) {
			v[i] = a[i];
		} else if (t[i] > 1) {
			v[i] = v[t[i]] + a[i];
			t[i] = t[t[i]];
		}
//		printf("i = %d, t = %d, v = %lld\n", i, t[i], v[i]);
	}
	rep(i, 1, n) {
		ll x = 1 + i, y = i;
		if (t[x] == 1) {
			puts("-1");
		} else {
			y += v[x];
			printf("%lld\n", y);
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
//-------head-------
const int N = 2e5 + 7;
int n, a[N], t[N];
ll v[N];
int main() {
	scanf("%d", &n);
	rep(i, 2, n + 1)
		scanf("%d", &a[i]);
	rep(i, 1, n + 1) {
		t[i] = i - a[i];
		if (t[i] <= 0) {
			v[i] = a[i];
		} else if (t[i] > 1) {
			v[i] = v[t[i]] + a[i];
		}
	}
	rep(i, 1, n) {
		ll x = 1 + i, y = i;
		if (t[x] == 1) {
			puts("-1");
		} else {
			y += v[x];
			printf("%lld\n", y);
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
//-------
const int N = 2e5 + 7;
int n, a[N], ts;
int t[N][2];
ll v[N][2];
ll dfs(int x, int d) {
	if (x < 1 || x > n)
		return 0;
	if (x == 1 || t[x][d] == ts)
		return -1;
	if (!t[x][d]) {
		t[x][d] = ts;
		int nx = x + (d ? -a[x] : a[x]);
		ll nv = dfs(nx, d ^ 1);
		if (nv == -1)
			return v[x][d] = -1;
		v[x][d] = nv + a[x];
	}
	return v[x][d];
}
int main() {
	scanf("%d", &n);
	rep(i, 2, n + 1)
		scanf("%d", &a[i]);
	ts = 0;
	rep(i, 1, n) {
		++ts;
		ll ans = dfs(1 + i, 1);
		printf("%lld\n", ans < 0 ? -1 : ans + i);
	}

	return 0;
}


#include "bits/stdc++.h"

using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define sqr(x) ((x)*(x))
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define NAME "sqrtnim"
#define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);
#define Freopen freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

typedef unsigned int unt;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef double geom;
typedef bitset < 300 > bb;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const ll INF64 = 7e18;
const ld EPS = 1e-9;
const ld PI = 3.14159265358979310000;
const ll MD = 535355424;
const int T = 1e5 * 3;
const int N = 400201;
const int M = 100;

ll n, a[N], d[3][N], b[3][N];
bool mark[3][N];

void dfs(int v, int t)
{
    mark[t][v] = 1;
    ll vv = v, tt = t;
    d[tt][vv] += a[v];
    if (!t)
        v += a[v];
    else
        v -= a[v];
    if (v <= 0 || v > n)
    {
        mark[tt][vv] = 2;
        return;
    }
    t = abs(t - 1);
    if (mark[t][v] == 1)
        d[tt][vv] = -1;
    else
        if (mark[t][v] == 2)
        {
            if (d[t][v] == -1)
                d[tt][vv] = -1;
            else
                d[tt][vv] += d[t][v];
        }
        else
        {
            dfs(v, t);
            if (d[t][v] == -1)
                d[tt][vv] = -1;
            else
                d[tt][vv] += d[t][v];
        }
    mark[tt][vv] = 2;
}

int main()
{
    cin >> n;
    for (int i = 2; i <= n; i++)
        scanf("%I64d", &a[i]);
    mark[0][1] = 1;
    mark[1][1] = 2;
    for (int i = 2; i <= n; i++)
        forn(j, 2)
            if (!mark[j][i])
                dfs(i, j);
    d[1][1] = -1;
    for (ll i = 1; i < n; i++)
    {
        int v = d[1][1 + i];
        if (v == -1)
            printf("-1\n");
        else
            printf("%I64d\n", i + v);
    }

    return 0;
}

/*

*/


#include "bits/stdc++.h"

using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define sqr(x) ((x)*(x))
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define NAME "sqrtnim"
#define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);
#define Freopen freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

typedef unsigned int unt;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef double geom;
typedef bitset < 300 > bb;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const ll INF64 = 7e18;
const ld EPS = 1e-9;
const ld PI = 3.14159265358979310000;
const ll MD = 535355424;
const int T = 1e5 * 3;
const int N = 400201;
const int M = 100;

ll n, a[N], d[3][N], b[3][N];
bool mark[3][N];

void dfs(int v, int t)
{

    mark[t][v] = 1;
    ll vv = v, tt = t;
    d[t][v] += a[v];
    if (!t)
        v += a[v];
    else
        v -= a[v];
    if (v <= 0 || v > n)
    {
        mark[t][vv] = 2;
        return;
    }
    t = abs(t - 1);
    if (mark[t][v] == 1)
        d[tt][vv] = -1;
    else
        if (mark[t][v] == 2)
        {
            if (d[t][v] == -1)
                d[tt][vv] = -1;
            else
                d[tt][vv] += d[t][v];
        }
        else
        {
            dfs(v, t);
            if (d[t][v] == -1)
                d[tt][vv] = -1;
            else
                d[tt][vv] += d[t][v];
        }
    mark[tt][vv] = 2;
}

int main()
{
    cin >> n;
    for (int i = 2; i <= n; i++)
        scanf("%I64d", &a[i]);
    for (int i = 2; i <= n; i++)
        forn(j, 2)
            if (!mark[j][i])
                dfs(i, j);
    mark[0][1] = 1;
    mark[1][1] = 2;
    d[1][1] = -1;
    for (ll i = 1; i < n; i++)
    {
        int v = d[1][1 + i];
        if (v == -1)
            printf("-1\n");
        else
            printf("%I64d\n", i + v);
    }

    return 0;
}

/*

*/


#include "bits/stdc++.h"

using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define sqr(x) ((x)*(x))
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define NAME "sqrtnim"
#define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);
#define Freopen freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

typedef unsigned int unt;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef double geom;
typedef bitset < 300 > bb;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const ll INF64 = 7e18;
const ld EPS = 1e-9;
const ld PI = 3.14159265358979310000;
const ll MD = 535355424;
const int T = 1e5 * 3;
const int N = 400201;
const int M = 100;

ll n, a[N], d[3][N], b[3][N];
bool mark[3][N], mm[3][N];

void dfs(int v, int t)
{
    mark[t][v] = 1;
    ll vv = v, tt = t;
    d[tt][vv] += a[v];
    if (!t)
        v += a[v];
    else
        v -= a[v];
    if (v <= 0 || v > n)
    {
        mark[tt][vv] = 2;
        return;
    }
    t = abs(t - 1);
    if (t == 1 && v == 1)
    {
        mm[tt][vv] = 1;
        mark[tt][vv] = 1;
        return;
    }
    if (mark[t][v] == 1)
        d[tt][vv] = -1;
    else
        if (mark[t][v] == 2)
        {
            if (d[t][v] == -1)
                d[tt][vv] = -1;
            else
                d[tt][vv] += d[t][v];
            mm[tt][vv] = mm[t][v];
        }
        else
        {
            dfs(v, t);
            if (d[t][v] == -1)
                d[tt][vv] = -1;
            else
                d[tt][vv] += d[t][v];
            mm[tt][vv] = mm[t][v];
        }
    mark[tt][vv] = 2;
}

int main()
{
    cin >> n;
    for (int i = 2; i <= n; i++)
        scanf("%I64d", &a[i]);
    mark[0][1] = 1;
    mark[1][1] = 2;
    d[0][1] = -1;
    for (int i = 2; i <= n; i++)
        forn(j, 2)
            if (!mark[j][i])
                dfs(i, j);
    for (ll i = 1; i < n; i++)
    {
        ll v = d[1][1 + i];
        ll s = 0;
        if (mm[1][1 + i])
            s += i;
        if (v == -1)
            printf("-1\n");
        else
            printf("%I64d\n", i + v + s);
    }

    return 0;
}

/*

*/


#include "bits/stdc++.h"

using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define sqr(x) ((x)*(x))
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define NAME "sqrtnim"
#define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);
#define Freopen freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

typedef unsigned int unt;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef double geom;
typedef bitset < 300 > bb;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const ll INF64 = 7e18;
const ld EPS = 1e-9;
const ld PI = 3.14159265358979310000;
const ll MD = 535355424;
const int T = 1e5 * 3;
const int N = 400201;
const int M = 100;

int n, a[N], d[3][N], b[3][N];
bool mark[3][N];

void dfs(int v, int t)
{

    mark[t][v] = 1;
    int vv = v, tt = t;
    d[t][v] += a[v];
    if (!t)
        v += a[v];
    else
        v -= a[v];
    if (v <= 0 || v > n)
    {
        mark[t][vv] = 2;
        return;
    }
    t = abs(t - 1);
    if (mark[t][v] == 1)
        d[tt][vv] = -1;
    else
        if (mark[t][v] == 2)
        {
            if (d[t][v] == -1)
                d[tt][vv] = -1;
            else
                d[tt][vv] += d[t][v];
        }
        else
        {
            dfs(v, t);
            if (d[t][v] == -1)
                d[tt][vv] = -1;
            else
                d[tt][vv] += d[t][v];
        }
    mark[tt][vv] = 2;
}

int main()
{
    cin >> n;
    for (int i = 2; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 2; i <= n; i++)
        forn(j, 2)
            if (!mark[j][i])
                dfs(i, j);
    for (int i = 1; i < n; i++)
    {
        int v = d[1][1 + i];
        if (v == -1)
            printf("-1\n");
        else
            printf("%d\n", i + v);
    }

    return 0;
}

/*

*/


#include "bits/stdc++.h"

using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define sqr(x) ((x)*(x))
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define NAME "sqrtnim"
#define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);
#define Freopen freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

typedef unsigned int unt;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef double geom;
typedef bitset < 300 > bb;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const ll INF64 = 7e18;
const ld EPS = 1e-9;
const ld PI = 3.14159265358979310000;
const ll MD = 535355424;
const int T = 1e5 * 3;
const int N = 400201;
const int M = 100;

ll n, a[N], d[3][N], b[3][N];
int mark[3][N], mm[3][N];

void dfs(int v, int t)
{
    mark[t][v] = 1;
    ll vv = v, tt = t;
    d[tt][vv] += a[v];
    if (!t)
        v += a[v];
    else
        v -= a[v];
    if (v <= 0 || v > n)
    {
        mark[tt][vv] = 2;
        return;
    }
    t = abs(t - 1);
    if (t == 1 && v == 1)
    {
        mm[tt][vv] = 1;
        mark[tt][vv] = 1;
        return;
    }
    if (mark[t][v] == 1)
        d[tt][vv] = -1;
    else
        if (mark[t][v] == 2)
        {
            if (d[t][v] == -1)
                d[tt][vv] = -1;
            else
                d[tt][vv] += d[t][v];
            mm[tt][vv] = mm[t][v];
        }
        else
        {
            dfs(v, t);
            if (d[t][v] == -1)
                d[tt][vv] = -1;
            else
                d[tt][vv] += d[t][v];
            mm[tt][vv] = mm[t][v];
        }
    mark[tt][vv] = 2;
}

int main()
{
    cin >> n;
    for (int i = 2; i <= n; i++)
        scanf("%I64d", &a[i]);
    mark[0][1] = 1;
    mark[1][1] = 2;
    d[0][1] = -1;
    for (int i = 2; i <= n; i++)
        forn(j, 2)
            if (!mark[j][i])
                dfs(i, j);
    for (ll i = 1; i < n; i++)
    {
        ll v = d[1][1 + i];
        ll s = 0;
        if (mm[1][1 + i])
            s += i;
        if (v == -1)
            printf("-1\n");
        else
            printf("%I64d\n", i + v + s);
    }

    return 0;
}

/*

*/


#include "bits/stdc++.h"

using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define sqr(x) ((x)*(x))
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define NAME "sqrtnim"
#define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);
#define Freopen freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

typedef unsigned int unt;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef double geom;
typedef bitset < 300 > bb;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const ll INF64 = 7e18;
const ld EPS = 1e-9;
const ld PI = 3.14159265358979310000;
const ll MD = 535355424;
const int T = 1e5 * 3;
const int N = 400201;
const int M = 100;

ll n, a[N], d[3][N], b[3][N];
bool mark[3][N];

void dfs(int v, int t)
{

    mark[t][v] = 1;
    ll vv = v, tt = t;
    d[t][v] += a[v];
    if (!t)
        v += a[v];
    else
        v -= a[v];
    if (v <= 0 || v > n)
    {
        mark[t][vv] = 2;
        return;
    }
    t = abs(t - 1);
    if (mark[t][v] == 1)
        d[tt][vv] = -1;
    else
        if (mark[t][v] == 2)
        {
            if (d[t][v] == -1)
                d[tt][vv] = -1;
            else
                d[tt][vv] += d[t][v];
        }
        else
        {
            dfs(v, t);
            if (d[t][v] == -1)
                d[tt][vv] = -1;
            else
                d[tt][vv] += d[t][v];
        }
    mark[tt][vv] = 2;
}

int main()
{
    cin >> n;
    for (int i = 2; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 2; i <= n; i++)
        forn(j, 2)
            if (!mark[j][i])
                dfs(i, j);
    for (ll i = 1; i < n; i++)
    {
        int v = d[1][1 + i];
        if (v == -1)
            printf("-1\n");
        else
            printf("%I64d\n", i + v);
    }

    return 0;
}

/*

*/


#include "bits/stdc++.h"

using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) int((a).size())
#define sqr(x) ((x)*(x))
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define NAME "sqrtnim"
#define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);
#define Freopen freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

typedef unsigned int unt;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef double geom;
typedef bitset < 300 > bb;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const ll INF64 = 7e18;
const ld EPS = 1e-9;
const ld PI = 3.14159265358979310000;
const ll MD = 535355424;
const int T = 1e5 * 3;
const int N = 400201;
const int M = 100;

ll n, a[N], d[3][N], b[3][N];
bool mark[3][N];

void dfs(int v, int t)
{

    mark[t][v] = 1;
    ll vv = v, tt = t;
    d[t][v] += a[v];
    if (!t)
        v += a[v];
    else
        v -= a[v];
    if (v <= 0 || v > n)
    {
        mark[t][vv] = 2;
        return;
    }
    t = abs(t - 1);
    if (mark[t][v] == 1)
        d[tt][vv] = -1;
    else
        if (mark[t][v] == 2)
        {
            if (d[t][v] == -1)
                d[tt][vv] = -1;
            else
                d[tt][vv] += d[t][v];
        }
        else
        {
            dfs(v, t);
            if (d[t][v] == -1)
                d[tt][vv] = -1;
            else
                d[tt][vv] += d[t][v];
        }
    mark[tt][vv] = 2;
}

int main()
{
    cin >> n;
    for (int i = 2; i <= n; i++)
        scanf("%I64d", &a[i]);
    for (int i = 2; i <= n; i++)
        forn(j, 2)
            if (!mark[j][i])
                dfs(i, j);
    mark[1][0] = 1;
    mark[1][1] = 2;
    d[1][1] = -1;
    for (ll i = 1; i < n; i++)
    {
        int v = d[1][1 + i];
        if (v == -1)
            printf("-1\n");
        else
            printf("%I64d\n", i + v);
    }

    return 0;
}

/*

*/


/* Author haleyk10198 */
/* �@��:  haleyk10198 */
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <string>
#include <set>
#include <stack>

#define MOD 1000000007
#define LINF (1LL<<60)
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))

using namespace std;
ll f[200010][2];
int a[200010],cyc[200100];
int gp[200010][2],n;

int gpcnt;

void build(int now,int dir){
	if(now==0){
		cyc[gpcnt]=dir;
		return;
	}
	if(gp[now][dir]){
		if(gp[now][dir]==gpcnt)
			cyc[gpcnt]=true;
		else if(cyc[gp[now][dir]])
			cyc[gpcnt]=true;
		return;
	}
	int nxt=now+a[now]*(dir?1:-1);
	gp[now][dir]=gpcnt;
	f[now][dir]=a[now];
	if(!(nxt<0||nxt>=n)){
		build(nxt,!dir);
		//INTERSTING RE HUH?
		f[now][dir]+=f[nxt][!dir];
	}
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<n;i++)
		cin>>a[i];
	for(int i=1;i<n;i++){
		if(!gp[i][0])
			gpcnt++,build(i,0);
	}
	for(int i=1;i<n;i++){
		if(cyc[gp[i][0]])
			cout<<-1<<endl;
		else
			cout<<f[i][0]+i<<endl;
	}
	return 0;
}


/* Author haleyk10198 */
/* �@��:  haleyk10198 */
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <string>
#include <set>
#include <stack>

#define MOD 1000000007
#define LINF (1LL<<60)
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))

using namespace std;
ll f[200010][2];
int a[200010],cyc[200100];
int gp[200010][2],n,out[200010];

int gpcnt;

void build(int now,int dir){
	if(now==0){
		cyc[gpcnt]=dir;
		return;
	}
	if(gp[now][dir]){
		if(gp[now][dir]==gpcnt)
			cyc[gpcnt]=true;
		else if(cyc[gp[now][dir]])
			cyc[gpcnt]=true;
		return;
	}
	int nxt=now+a[now]*(dir?1:-1);
	gp[now][dir]=gpcnt;
	f[now][dir]=a[now];
	if(!(nxt<0||nxt>=n))
		build(nxt,!dir);
	f[now][dir]+=f[nxt][!dir];
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<n;i++)
		cin>>a[i];
	for(int i=1;i<n;i++){
		if(!gp[i][0])
			gpcnt++,build(i,0);
	}
	for(int i=1;i<n;i++){
		int cur=gp[i][0];
		if(cyc[cur])
			out[i]=-1;
		else
			out[i]=i+f[i][0];
	}
	for(int i=1;i<n;i++)
		cout<<out[i]<<endl;
	return 0;
}


/* Author haleyk10198 */
/* �@��:  haleyk10198 */
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <string>
#include <set>
#include <stack>

#define MOD 1000000007
#define LINF (1LL<<60)
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))

using namespace std;
ll f[200010][2];
int a[200010],cyc[400100];
int gp[200010][2],n,out[200010];

int gpcnt;

void build(int now,int dir){
	if(now==0){
		cyc[gpcnt]=dir;
		return;
	}
	if(gp[now][dir]){
		if(gp[now][dir]==gpcnt)
			cyc[gpcnt]=true;
		else if(cyc[gp[now][dir]])
			cyc[gpcnt]=true;
		return;
	}
	int nxt=now+a[now]*(dir?1:-1);
	gp[now][dir]=gpcnt;
	f[now][dir]=a[now];
	if(!(nxt<0||nxt>=n))
		build(nxt,!dir);
	f[now][dir]+=f[nxt][!dir];
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<n;i++)
		cin>>a[i];
	for(int i=1;i<n;i++){
		if(!gp[i][0])
			gpcnt++,build(i,0);
		if(!gp[i][1])
			gpcnt++,build(i,1);
	}
	for(int i=1;i<n;i++){
		int cur=gp[i][0];
		if(cyc[cur])
			out[i]=-1;
		else
			out[i]=i+f[i][0];
	}
	for(int i=1;i<n;i++)
		cout<<out[i]<<endl;
	return 0;
}


/* Author haleyk10198 */
/* �@��:  haleyk10198 */
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <string>
#include <set>
#include <stack>

#define MOD 1000000007
#define LINF (1LL<<60)
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))

using namespace std;
int f[200010][2],a[200010],cyc[400010],sz[400010];
int gp[200010][2],n,out[200010];

int gpcnt;

void build(int now,int dir){
	if(now==0){
		cyc[gpcnt]=dir;
		return;
	}
	if(gp[now][dir]){
		if(gp[now][dir]==gpcnt)
			cyc[gpcnt]=true;
		else if(cyc[gp[now][dir]])
			cyc[gpcnt]=true;
		return;
	}
	int nxt=now+a[now]*(dir?1:-1);
	gp[now][dir]=gpcnt;
	sz[gpcnt]++;
	f[now][dir]=a[now];
	if(!(nxt<0||nxt>=n))
		build(nxt,!dir);
	f[now][dir]+=f[nxt][!dir];
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<n;i++)
		cin>>a[i];
	for(int i=1;i<n;i++){
		if(!gp[i][0])
			gpcnt++,build(i,0);
		if(!gp[i][1])
			gpcnt++,build(i,1);
	}
	for(int i=1;i<n;i++){
		int pos=i;
		int cur=gp[i][0];
		if(cyc[cur])
			out[i]=-1;
		else
			out[i]=i+f[i][0];
	}
	for(int i=1;i<n;i++)
		cout<<out[i]<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
typedef long long ll;

ll dp[maxn][3];
bool v[maxn][3];
ll a[maxn];
	int n;

void dfs(int i,int j)
{
	if(v[i][j])return;
	v[i][j]=1;
	int nxt=j==1?i-a[i]:i+a[i];
	if(nxt>n||nxt<=0)
	{
		dp[i][j]=a[i];
		return;
	}
	dfs(nxt,j^1);
	if(dp[nxt][j^1]!=-1)dp[i][j]=dp[nxt][j^1]+a[i];
	return;
}
int main()
{
	memset(v,0,sizeof(v));

	scanf("%d",&n);

	for(int i=2;i<=n;i++)
	scanf("%I64d",&a[i]);

	memset(dp,-1,sizeof(dp));

	for(int i=2;i<=n;i++)dfs(i,1);
	for(int i=2;i<=n;i++)
	printf("%I64d\n",dp[i][1]==-1?dp[i][1]:dp[i][1]+i-1);
	return 0;
}


#include<bits/stdc++.h>
#define nn 200050
using namespace std;
typedef long long ll;
int n;
ll dp[nn][2];
int a[nn];
bool vis[nn][2];
void dfs(int w,int f){
	if (vis[w][f])return;
		vis[w][f]=1;
	int nex=w;
	if (f)nex+=a[w];
	else nex-=a[w];
	if (nex<=0||nex>n)dp[w][f]=a[w];
	else {
		dfs(nex,f^1);
		if (dp[nex][f^1]!=-1)
		dp[w][f]=a[w]+dp[nex][f^1];

	}
	return;
}
int main(){
	// 0->left   1->right
	scanf("%d",&n);
	for (int i=2;i<=n;i++)scanf("%d",&a[i]);
	memset(vis,0,sizeof(vis));
	memset(dp,-1,sizeof(dp));
	vis[1][0]=vis[1][1]=true;

	for (int i=2;i<=n;i++){
		dfs(i,0);
		if (dp[i][0]!=-1)
		printf("%I64d\n",1ll*i-1+dp[i][0]);
		else puts("-1");
	}
	return 0;
}


#include<bits/stdc++.h>
#define nn 200050
using namespace std;
typedef long long ll;
int n;
ll x,y,X;
int a[nn];
map<ll,int>f;
int main(){
	scanf("%d",&n);
	for (int i=2;i<=n;i++)scanf("%d",&a[i]);
	for (int i=1;i<n;i++){
		x=1;y=0;a[1]=i;

		while (x>0&&x<=n&&f[x]!=i){
			f[x]=i;
			X=x;
			x+=a[X];y+=a[X];
			X=x;
			x-=a[X];y+=a[X];
		}
		if (f[x]==i)puts("-1");else
		printf("%I64d\n",y);
	}
	return 0;
}


#include<bits/stdc++.h>
#define nn 200050
using namespace std;
typedef long long ll;
int n;
ll dp[nn][2];
int a[nn];
bool vis[nn][2];
void dfs(int w,int f){
	if (vis[w][f])return;
		vis[w][f]=1;
	int nex=w;
	if (f)nex+=a[w];
	else nex-=a[w];
	if (nex<=0||nex>n)dp[w][f]=a[w];
	else {
		dfs(nex,f^1);
		if (dp[nex][f^1]!=-1)
		dp[w][f]=a[w]+dp[nex][f^1];

	}
	return;
}
int main(){
	// 0->left   1->right
	scanf("%d",&n);
	for (int i=2;i<=n;i++)scanf("%d",&a[i]);
	memset(vis,0,sizeof(vis));
	memset(dp,-1,sizeof(dp));
	vis[1][0]=vis[1][1]=true;

	for (int i=2;i<=n;i++){
		dfs(i,0);
		if (dp[i][0]!=-1)
		printf("%d\n",i-1+dp[i][0]);
		else puts("-1");
	}
	return 0;
}


#include<bits/stdc++.h>
#define nn 200050
using namespace std;
typedef long long ll;
int n,x,y,X;
int a[nn];
map<int,int>f;
int main(){
	scanf("%d",&n);
	for (int i=2;i<=n;i++)scanf("%d",&a[i]);
	for (int i=1;i<n;i++){
		x=1;y=0;a[1]=i;

		while (x>0&&x<=n&&f[x]!=i){
			f[x]=i;
			X=x;
			x+=a[X];y+=a[X];
			X=x;
			x-=a[X];y+=a[X];
		}
		if (f[x]==i)puts("-1");else
		printf("%d\n",y);
	}
	return 0;
}


#include<bits/stdc++.h>
#define nn 200050
using namespace std;
typedef long long ll;
ll n;
ll x,y,X;
ll a[nn];
map<ll,ll>f;
int main(){
	scanf("%I64d",&n);
	for (int i=2;i<=n;i++)scanf("%I64d",&a[i]);
	for (int i=1;i<n;i++){
		x=1;y=0;a[1]=i;

		while (x>0&&x<=n&&f[x]!=i){
			f[x]=i;
			X=x;
			x+=a[X];y+=a[X];
			X=x;
			if (X<=0||X>n)break;

			x-=a[X];y+=a[X];
		}
		if (x<=0||x>n)	printf("%I64d\n",y);
		else puts("-1");
	}
	return 0;
}


#include<bits/stdc++.h>
#define nn 200050
using namespace std;
typedef long long ll;
ll n;
ll x,y,X;
ll a[nn];
map<ll,ll>f;
int main(){
	scanf("%I64d",&n);
	for (int i=2;i<=n;i++)scanf("%I64d",&a[i]);
	for (int i=1;i<n;i++){
		x=1;y=0;a[1]=i;

		while (x>0&&x<=n&&f[x]!=i){
			f[x]=i;
			X=x;
			x+=a[X];y+=a[X];
			X=x;
			x-=a[X];y+=a[X];
		}
		if (x<=0||x>n)	printf("%I64d\n",y);
		else puts("-1");
	}
	return 0;
}


#include<bits/stdc++.h>
#define nn 200050
using namespace std;
typedef long long ll;
int n;
ll dp[nn][2];
int a[nn];
bool vis[nn][2];
void dfs(int w,int f){
	if (vis[w][f])return;

	int nex=w;
	if (f)nex+=a[w];
	else nex-=a[w];
	if (nex<=0||nex>n)dp[w][f]=a[w];
	else {
		dfs(nex,f^1);
		if (dp[nex][f^1]!=-1)
		dp[w][f]=a[w]+dp[nex][f^1];
	}
	return;
}
int main(){
	// 0->left   1->right
	scanf("%d",&n);
	for (int i=2;i<=n;i++)scanf("%d",&a[i]);
	memset(vis,0,sizeof(vis));
	memset(dp,-1,sizeof(dp));
	vis[1][0]=vis[1][1]=true;

	for (int i=2;i<=n;i++){
		dfs(i,0);
		if (dp[i][0]!=-1)
		printf("%d\n",i-1+dp[i][0]);
		else puts("-1");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long int  dp[200009][2];
long long int an[200009][2];
int a[200009];
int n;
void dfs(int x,int j)
{
    if(an[x][j])
    {
        return ;
    }
    an[x][j]=1;
    int y=j?(x-a[x]):(x+a[x]);
    if(y>n||y<=0)
    {
        dp[x][j]=a[x];
    }
    else
    {
        dfs(y,j^1);
        if(dp[y][j^1]!=-1)
        {
            dp[x][j]=dp[y][j^1]+a[x];
        }
    }
}
int main()
{
    while(cin>>n)
    {

        for(int i=2; i<=n; i++)
            cin>>a[i];
        memset(dp,-1,sizeof(dp));
        memset(an,0,sizeof(an));
        for(int i=2;i<=n;i++)
            dfs(i,1);
        for(int i=2; i<=n; i++)
        {
            if(dp[i][1]!=-1)
                dp[i][1]+=i-1;
            cout<<dp[i][1]<<endl;
        }
    }

}

		  	 								 					  		 				//hellobig_tq//hello


//In the name of God! :)

#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair <int, int>

using namespace std;

typedef long long ll;
const int maxn = 2e5 + 10;
int  n, val[maxn]; ll ans[maxn][2];
vector < pii > adj[maxn][2];
bool mark[maxn][2], last[maxn][2];

void dfs (int v, int t, bool b){
	mark[v][t] = true;
	last[v][t] = b;
	if (v == 1 && t == 1)
		b = true;
	for (int i = 0; i < (int)adj[v][t].size(); i++){
		int u = adj[v][t][i].F, t1 = adj[v][t][i].S;
		if (!mark[u][t1]){
			ans[u][t1] = 1ll * (ans[v][t] + val[u]);
			dfs (u, t1, b);
		}
	}
}

int main (){
	ios::sync_with_stdio (false);	cin.tie (NULL);
	cin>>n;
	for (int i = 2; i <= n; i++){
		int a;	cin>>a;	val[i] = a;
		if (a + i > n){
			adj[i][0].pb (mp (0, 0));
			adj[0][0].pb (mp (i, 0));
		}
		else{
			adj[i][0].pb (mp (i + a, 1));
			adj[i + a][1].pb (mp (i, 0));
		}
		if (i - a <= 0){
			adj[i][1].pb (mp (0, 0));
			adj[0][0].pb (mp (i, 1));
		}
		else{
			adj[i][1].pb (mp (i - a, 0));
			adj[i - a][0].pb (mp (i, 1));
		}
		ans[i][0] = ans[i][1] = -2;
	}
	adj[1][1].pb (mp (0, 0));
	ans[0][0] = 0;
	dfs (0, 0, 0);
	for (int i = 2; i <= n; i++){
		if (last[i][1])
			cout<<1ll * (ans[i][1] + 2 * (i - 1)) <<endl;
		else
		cout<<1ll *  (ans[i][1] + i - 1)<<endl;
	}
	return 0;
}


//In the name of God! :)

#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair <int, int>

using namespace std;

typedef long long ll;
const int maxn = 2e5 + 10;
int  n, val[maxn]; ll ans[maxn][2];
vector < pii > adj[maxn][2];
bool mark[maxn][2], last[maxn][2];

void dfs (int v, int t, bool b){
	mark[v][t] = true;
	last[v][t] = b;
	if (v == 1 && t == 1)
		b = true;
	for (int i = 0; i < (int)adj[v][t].size(); i++){
		int u = adj[v][t][i].F, t1 = adj[v][t][i].S;
		if (!mark[u][t1]){
			ans[u][t1] = 1ll * (ans[v][t] + val[u]);
			dfs (u, t1, b);
		}
	}
}

int main (){
	ios::sync_with_stdio (false);	cin.tie (NULL);
	cin>>n;
	for (int i = 2; i <= n; i++){
		int a;	cin>>a;	val[i] = a;
		if (a + i > n){
			adj[i][0].pb (mp (0, 0));
			adj[0][0].pb (mp (i, 0));
		}
		else{
			adj[i][0].pb (mp (i + a, 1));
			adj[i + a][1].pb (mp (i, 0));
		}
		if (i - a <= 0){
			adj[i][1].pb (mp (0, 0));
			adj[0][0].pb (mp (i, 1));
		}
		else{
			adj[i][1].pb (mp (i - a, 0));
			adj[i - a][0].pb (mp (i, 1));
		}
		ans[i][0] = ans[i][1] = -2;
	}
	adj[1][1].pb (mp (0, 0));
	ans[0][0] = 0;
	dfs (0, 0, 0);
	for (int i = 2; i <= n; i++){
		if (!mark[i][1]){
			cout<<-1<<endl;
			continue;
		}
		if (last[i][1])
			cout<<1ll * (ans[i][1] + 2 * (i - 1)) <<endl;
		else
		cout<<1ll *  (ans[i][1] + i - 1)<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long int  dp[200009][2];
long long int an[200009][2];
int a[200009];
int n;
void dfs(int x,int j)
{
    if(an[x][j])
    {
        return ;
    }
    an[x][j]=1;
    int y=j?(x-a[x]):(x+a[x]);
    if(y>n||y<=0)
    {
        dp[x][j]=a[x];
    }
    else
    {
        dfs(y,j^1);
        if(dp[y][j^1]!=-1)
        {
            dp[x][j]=dp[y][j^1]+a[x];
        }
    }
}
int main()
{
    while(cin>>n)
    {

        for(int i=2; i<=n; i++)
            cin>>a[i];
        memset(dp,-1,sizeof(dp));
        memset(an,0,sizeof(an));
        for(int i=2;i<=n;i++)
            dfs(i,1);
        for(int i=2; i<=n; i++)
        {
            if(dp[i][1]!=-1)
                dp[i][1]+=i-1;
            cout<<dp[i][1]<<endl;
        }
    }

}

		  	 								 					  		 				//hellobig_tq//hello//hello


#include<bits/stdc++.h>

using namespace std;
const int N=2e5+1;
int a[N];
int vis[N];
int main()
{
    int n,i;
    cin>>n;
    int x,y,count;
    for(i=2;i<=n;i++)
        cin>>a[i];
    for(i=1;i<n;i++)
    {
      x=1;y=0;count=0;

      a[1]=i;
      int flag=0;
      while(x>0 && x<=n)
      {
       if(count>n)
       {flag=1;break;}

       if(count%2==0)
       {count++;y=y+a[x];x+=a[x];}
       else
       {count++;y=y+a[x];x=x-a[x];}

      }

    if(!flag)
      cout<<y<<endl;
    else
        cout<<"-1"<<endl;
    }
 return 0;
}


#include<bits/stdc++.h>

using namespace std;
const int N=2e5+1;
int s[N][2];
long long v[N][2];
long long a[N];
int n;
long long dfs(int u,int d)
{
 if(u<=0 || u>n)
  return 0;
 if(s[u][d]==1)
     return -1;
 if(s[u][d]==2)
     return v[u][d];
 s[u][d]=1;
 if(d)
     v[u][d]=dfs(u-a[u],0);
 else
     v[u][d]=dfs(u+a[u],1);
//cout<<"u is : "<<u<<"  "<<"D is :"<<d<<endl;
// cout<<"s[u][d] is "<<s[u][d]<<endl;
 //cout<<"v[u][d] is"<<v[u][d]<<endl;
 if(v[u][d]>=0)
     v[u][d]+=a[u];
 s[u][d]=2;
 return v[u][d];
}
int main()
{
    int i;
    s[1][1]=1;
    s[1][0]=1;
    cin>>n;
    int x,y,count;
    for(i=2;i<=n;i++)
        cin>>a[i];
 //   int x,y;
    long long val;

    for(i=1;i<n;i++)
    {
     val=dfs(i+1,1);
     //cout<<"val is"<<val<<endl;
     if(val==-1)
         cout<<val<<endl;
     else
         cout<<val+i<<endl;

    }
 return 0;
}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

#define all(x) x.begin(), x.end()
#define f(i,a,b) for(int i = (a); i <= (b); i++)
#define fd(i,a,b) for(int i = (a); i >= (b); i--)
#define mp make_pair
#define faster_io() ios_base::sync_with_stdio(false)
#define pb push_back
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
#define vii vector<pair<int,int>>

const int INF = 1000000002;
const ll INFLL = 100000000000000000ll;
const ll MOD = 1000000007;

// ----------------------------------------------------------------------------------------------------------

const int MAX = 200005;
bool Mark[MAX][2];
int Good[MAX][2];
int N, A[MAX];
ll D[MAX][2], End;

int dfs(int i, int step, ll sum)
{
    End = max(End, sum);
    if(i<1 || i>N) return 1;
    if(i == 1)
    {
        if(step == 0) return 0;
        else return 2;
    }

    if(Good[i][step])
    {
        End = max(End, D[i][step] + sum);
        return Good[i][step];
    }
    if(Mark[i][step]) return Good[i][step] = 0;
    Mark[i][step] = true;

    if(step)
    {
        bool val = dfs(i-A[i],1-step,sum+A[i]);
        if(val) D[i][step] = End - sum;
        return Good[i][step] = val;
    }
    else
    {
        bool val = dfs(i+A[i],1-step,sum+A[i]);
        if(val) D[i][step] = End - sum;
        return Good[i][step] = val;
    }
}

int main()
{
    cin >> N;
    f(i,2,N) scanf("%d", &A[i]);
    f(i,1,N-1) if(!Mark[i+1][1])
    {
        End = 0;
        dfs(i+1,1,i);
    }
    f(i,1,N-1)
    {
        if(Good[i+1][1] == 1) printf("%I64d\n", D[i+1][1] + i);
        else if(Good[i+1][1] == 2) printf("%I64d\n", D[i+1][1] + i + i);
        else printf("-1\n");
    }
}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

#define all(x) x.begin(), x.end()
#define f(i,a,b) for(int i = (a); i <= (b); i++)
#define fd(i,a,b) for(int i = (a); i >= (b); i--)
#define mp make_pair
#define faster_io() ios_base::sync_with_stdio(false)
#define pb push_back
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
#define vii vector<pair<int,int>>

const int INF = 1000000002;
const ll INFLL = 100000000000000000ll;
const ll MOD = 1000000007;

// ----------------------------------------------------------------------------------------------------------

const int MAX = 200005;
bool Mark[MAX][2];
int Good[MAX][2];
int N, A[MAX];
ll D[MAX][2], End;

int dfs(int i, int step, ll sum)
{
    cout << i << " " << step << " " << sum << "\n";
    End = max(End, sum);
    if(i<1 || i>N) return 1;
    if(i == 1)
    {
        if(step == 0) return 0;
        else return 2;
    }

    if(Mark[i][step]) return Good[i][step] = 0;
    Mark[i][step] = true;

    if(step)
    {
        bool val = dfs(i-A[i],1-step,sum+A[i]);
        if(val) D[i][step] = End - sum;
        return Good[i][step] = val;
    }
    else
    {
        bool val = dfs(i+A[i],1-step,sum+A[i]);
        if(val) D[i][step] = End - sum;
        return Good[i][step] = val;
    }
}

int main()
{
    cin >> N;
    f(i,2,N) scanf("%d", &A[i]);
    f(i,1,N-1) if(!Mark[i+1][1])
    {
        End = 0;
        dfs(i+1,1,i);
    }
    f(i,1,N-1)
    {
        if(Good[i+1][1] == 1) printf("%I64d\n", D[i+1][1] + i);
        else if(Good[i+1][1] == 2) printf("%I64d\n", D[i+1][1] + i + i);
        else printf("-1\n");
    }
}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

#define all(x) x.begin(), x.end()
#define f(i,a,b) for(int i = (a); i <= (b); i++)
#define fd(i,a,b) for(int i = (a); i >= (b); i--)
#define mp make_pair
#define faster_io() ios_base::sync_with_stdio(false)
#define pb push_back
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
#define vii vector<pair<int,int>>

const int INF = 1000000002;
const ll INFLL = 100000000000000000ll;
const ll MOD = 1000000007;

// ----------------------------------------------------------------------------------------------------------

const int MAX = 200005;
bool Good[MAX][2], Mark[MAX][2];
int N, A[MAX];
ll D[MAX][2], End;

bool dfs(int i, int step, ll sum)
{
    End = max(End, sum);
    if(i<1 || i>N) return Good[i][step] = true;

    if(Mark[i][step]) return Good[i][step] = false;
    Mark[i][step] = true;

    if(step)
    {
        bool val = dfs(i-A[i],1-step,sum+A[i]);
        if(val) D[i][step] = End - sum;
        return Good[i][step] = val;
    }
    else
    {
        bool val = dfs(i+A[i],1-step,sum+A[i]);
        if(val) D[i][step] = End - sum;
        return Good[i][step] = val;
    }
}

int main()
{
    cin >> N;
    f(i,2,N) scanf("%d", &A[i]);
    f(i,1,N-1) if(!Mark[i][0])
    {
        End = 0;
        dfs(i+1,1,i);
    }
    f(i,1,N-1)
    {
        if(Good[i+1][1]) printf("%I64d\n", D[i+1][1] + i);
        else printf("-1\n");
    }
}


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

const int MAXN = 200005;
const long long MAXVAL = 2000000000000005LL;

long long memo[MAXN][2];
int a[MAXN];

int n;
long long get_ans(int i, bool op) {
    if (i > n || i <= 0) return 0;

    long long &ret = memo[i][op];

    if (ret < -1) return -MAXVAL;
    if (ret == -1) {
        ret = -2;
        long long tempret;
        if (op) {
            tempret = a[i] + get_ans(i - a[i], !op);
        } else {
            tempret = a[i] + get_ans(i + a[i], !op);
        }
        ret = tempret;
    }
    return ret;
}

int main() {
    memset(memo, -1, sizeof memo);

    scanf("%d", &n);

    for (int i = 2; i <= n; ++i) scanf("%d", a + i);

    memo[1][0] = -2;

    for (int i = 2; i <= n; ++i) {
        long long ans = get_ans(i, 1);
        if (ans < 0) {
            cout << -1 << endl;
        } else {
            cout << ans + i - 1 << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>

typedef long long lld;

lld N;
lld a[200010];
lld d[200010][3];
bool imp[200010][3];
bool flag[200010][3];
bool check[200010][3];

void dfs(lld x,lld y){
    check[x][y] = true;
    if(y == 1){
        if(x+a[x] > N){
            d[x][y] = a[x];
            return;
        }
        if(!check[x+a[x]][3-y]){
            dfs(x+a[x],3-y);
            imp[x][y] = imp[x+a[x]][3-y];
            flag[x][y] = flag[x+a[x]][3-y];
            d[x][y] = d[x+a[x]][3-y]+a[x];
        }else{
            imp[x][y] = true;
        }
    }else{
        if(x-a[x] <= 0){
            d[x][y] = a[x];
            return;
        }
        if(x-a[x] == 1 && 3-y == 2){
            flag[x][y] = true;
            d[x][y] = a[x];
            return;
        }else if(!check[x-a[x]][3-y]){
            dfs(x-a[x],3-y);
            imp[x][y] = imp[x-a[x]][3-y];
            flag[x][y] = flag[x-a[x]][3-y];
            d[x][y] = d[x-a[x]][3-y]+a[x];
        }else{
            imp[x][y] = true;
        }
    }
}

int main(){
    //freopen("input.txt","r",stdin);

    scanf("%lld",&N);
    for(lld i=2; i<=N; i++) scanf("%lld",&a[i]);
    check[1][1] = true; imp[1][1] = true;
    for(lld i=2; i<=N; i++){
        if(!check[i][1]) dfs(i,1);
        if(!check[i][2]) dfs(i,2);
    }
    for(lld i=1; i<N; i++){
        if(imp[i+1][2]) printf("-1\n");
        else if(flag[i+1][2]){
            lld ans = d[i+1][2];
            ans += i;
            printf("%lld\n",ans);
        }else printf("%lld\n",d[i+1][2]+i);
    }

    return 0;
}


#include <bits/stdc++.h>

typedef long long lld;

lld N;
lld a[200010];
lld d[200010][3];
bool imp[200010][3];
bool check[200010][3];

void dfs(lld x,lld y){
    check[x][y] = true;
    if(y == 1){
        if(x+a[x] > N){
            d[x][y] = a[x];
            return;
        }
        if(!check[x+a[x]][3-y]){
            dfs(x+a[x],3-y);
            imp[x][y] = imp[x+a[x]][3-y];
            d[x][y] = d[x+a[x]][3-y]+a[x];
        }else{
            imp[x][y] = true;
        }
    }else{
        if(x-a[x] <= 0){
            d[x][y] = a[x];
            return;
        }
        if(!check[x-a[x]][3-y]){
            dfs(x-a[x],3-y);
            imp[x][y] = imp[x-a[x]][3-y];
            d[x][y] = d[x-a[x]][3-y]+a[x];
        }else{
            imp[x][y] = true;
        }
    }
}

int main(){
    //freopen("input.txt","r",stdin);

    scanf("%lld",&N);
    for(lld i=2; i<=N; i++) scanf("%lld",&a[i]);
    check[1][1] = true; imp[1][1] = true;
    dfs(1,2);
    for(lld i=2; i<=N; i++){
        if(!check[i][1]) dfs(i,1);
        if(!check[i][2]) dfs(i,2);
    }
    for(lld i=1; i<N; i++){
        if(imp[i+1][2]) printf("-1\n");
        else printf("%lld\n",d[i+1][2]+i);
    }

    return 0;
}


#include <bits/stdc++.h>

typedef long long lld;

lld N;
lld a[200010];
lld d[200010][3];
bool imp[200010][3];
bool flag[200010][3];
bool check[200010][3];

void dfs(lld x,lld y){
    check[x][y] = true;
    if(y == 1){
        if(x+a[x] > N){
            d[x][y] = a[x];
            return;
        }
        if(!check[x+a[x]][3-y]){
            dfs(x+a[x],3-y);
            imp[x][y] = imp[x+a[x]][3-y];
            flag[x][y] = flag[x+a[x]][3-y];
            d[x][y] = d[x+a[x]][3-y]+a[x];
        }else{
            imp[x][y] = true;
        }
    }else{
        if(x-a[x] <= 0){
            d[x][y] = a[x];
            return;
        }
        if(x-a[x] == 1 && 3-y == 2){
            flag[x][y] = true;
            d[x][y] = a[x];
            return;
        }else if(!check[x-a[x]][3-y]){
            dfs(x-a[x],3-y);
            imp[x][y] = imp[x-a[x]][3-y];
            flag[x][y] = flag[x-a[x]][3-y];
            d[x][y] = d[x-a[x]][3-y]+a[x];
        }else{
            imp[x][y] = true;
        }
    }
}

int main(){
    //freopen("input.txt","r",stdin);

    scanf("%lld",&N);
    for(lld i=2; i<=N; i++) scanf("%lld",&a[i]);
    check[1][1] = true; imp[1][1] = true;
    check[1][2] = true;
    for(lld i=2; i<=N; i++){
        if(!check[i][1]) dfs(i,1);
        if(!check[i][2]) dfs(i,2);
    }
    for(lld i=1; i<N; i++){
        if(imp[i+1][2]) printf("-1\n");
        else if(flag[i+1][2]){
            lld ans = d[i+1][2];
            ans += i;
            printf("%lld\n",ans);
        }else printf("%lld\n",d[i+1][2]+i);
    }

    return 0;
}


#include <bits/stdc++.h>

typedef long long lld;

int N;
int a[200010];
lld d[200010][3];
bool imp[200010][3];
bool check[200010][3];

void dfs(int x,int y){
    check[x][y] = true;
    if(y == 1){
        if(x+a[x] > N){
            d[x][y] = a[x];
            return;
        }
        if(!check[x+a[x]][3-y]){
            dfs(x+a[x],3-y);
            imp[x][y] = imp[x+a[x]][3-y];
            d[x][y] = d[x+a[x]][3-y]+a[x];
        }else{
            imp[x][y] = true;
        }
    }else{
        if(x-a[x] <= 0){
            d[x][y] = a[x];
            return;
        }
        if(!check[x-a[x]][3-y]){
            dfs(x-a[x],3-y);
            imp[x][y] = imp[x-a[x]][3-y];
            d[x][y] = d[x-a[x]][3-y]+a[x];
        }else{
            imp[x][y] = true;
        }
    }
}

int main(){
    //freopen("input.txt","r",stdin);

    scanf("%d",&N);
    for(int i=2; i<=N; i++) scanf("%d",&a[i]);
    for(a[1] = 1; a[1]<N; a[1]++){
        memset(check,0,sizeof(check));
        dfs(1,1);
        if(imp[1][1]) printf("-1\n");
        else printf("%lld\n",d[1][1]);
    }

    return 0;
}


#include <bits/stdc++.h>

typedef long long lld;

lld N;
lld a[200010];
lld d[200010][3];
bool imp[200010][3];
bool flag[200010][3];
bool check[200010][3];

void dfs(lld x,lld y){
    check[x][y] = true;
    if(y == 1){
        if(x+a[x] > N){
            d[x][y] = a[x];
            return;
        }
        if(!check[x+a[x]][3-y]){
            dfs(x+a[x],3-y);
            imp[x][y] = imp[x+a[x]][3-y];
            flag[x][y] = flag[x+a[x]][3-y];
            d[x][y] = d[x+a[x]][3-y]+a[x];
        }else{
            imp[x][y] = true;
        }
    }else{
        if(x-a[x] <= 0){
            d[x][y] = a[x];
            return;
        }
        if(x-a[x] == 1 && 3-y == 2){
            flag[x][y] = true;
            while(true);
            d[x][y] = a[x];
            return;
        }else if(!check[x-a[x]][3-y]){
            dfs(x-a[x],3-y);
            imp[x][y] = imp[x-a[x]][3-y];
            flag[x][y] = flag[x-a[x]][3-y];
            d[x][y] = d[x-a[x]][3-y]+a[x];
        }else{
            imp[x][y] = true;
        }
    }
}

int main(){
    //freopen("input.txt","r",stdin);

    scanf("%lld",&N);
    for(lld i=2; i<=N; i++) scanf("%lld",&a[i]);
    check[1][1] = true; imp[1][1] = true;
    for(lld i=2; i<=N; i++){
        if(!check[i][1]) dfs(i,1);
        if(!check[i][2]) dfs(i,2);
    }
    for(lld i=1; i<N; i++){
        if(imp[i+1][2]) printf("-1\n");
        else if(flag[i+1][2]){
            lld ans = d[i+1][2];
            ans += i;
            printf("%lld\n",ans);
        }else{
            printf("%lld\n",d[i+1][2]+i);
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, ll> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }

int n;
int a[200009];
pii memo[200009][2];
int seen[200009][2];
const int ok = 0, imp = 1, a1 = 2;
pii solve(int i, bool on2) {
	if(i < 0 || i >= n) return pii(ok, 0);
	if(i == 0 && on2) return pii(imp, 0);
	if(i == 0) return pii(a1, 0);
	pii &r = memo[i][on2];
	if(seen[i][on2] == 2) return r;
	if(seen[i][on2] == 1) return r = pii(imp, 0);
	seen[i][on2] = 1;
	pii x = solve(i + a[i] * (on2 * 2 - 1), !on2);
	r = x;
	if(r.fst != imp)
		r.snd += a[i];
	seen[i][on2] = 2;
	return r;
}

int main() {
	int i;
	scanf("%d", &n);
	for(i = 1; i < n; i++)
		scanf("%d", &a[i]);
	for(i = 0; i < n - 1; i++) {
		pii y = solve(i + 1, false);
		y.snd += i + 1;
		if(y.fst == a1) y.snd += i + 1;
		if(y.fst == imp) puts("-1");
		else printf("%I64d\n", y.snd);
	}

}


#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define ipp(n) printf("%d\n",n)
#define pp(n) printf("%lld\n",n)
#define pps(n) printf("%lld ",n)
#define ipps(n) printf("%d ",n)
#define all(x) x.begin(),x.end()
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define iis(n) scanf("%d",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld>
#define pi acos(-1)
#ifdef G
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<' '<<#zz<<' '<<zz<<endl;
#else
#define dg(x) ;
#define dg2(x,y) ;
#define dg3(x,y,z) ;
#define dg4(x,y,z,zz) ;
#endif
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ids(n,m) scanf("%d %d",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
#define its(n,m,k) scanf("%d %d %d",&n,&m,&k)
#define yes printf("YES\n")
#define no printf("NO\n")
#define isset(num,i) ((num&(1LL<<i))!=0)
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =2e5+10;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld ans,k,n,m,mymax=LLONG_MIN,mymin=LLONG_MAX,b,c,z,sum;
vector<lld> v[M];
lld visit[M],visit2[M];
lld x[M],y[M],a[M];
lld start_time[M],end_time[M],curr_time;
pll next(lld node)
{
	lld tempx=node+a[node],tempy=a[node];
	dg3(node,tempx,tempy);
	if(tempx>n||tempx<=0){
		return {-1,tempy};
	}
	tempy+=a[tempx];
	tempx-=a[tempx];
	return {tempx,tempy};
}
lld dfs(lld node)

{
	lld tempx,tempy;
	visit[node]=1;
	start_time[node]=curr_time++;
	pll temp=next(node);
	tempx=temp.F;
	tempy=temp.S;
	if(tempx==-1){
		y[node]=tempy;
		end_time[node]=curr_time;
		return  0;
	}
	dg3(node,tempx,tempy);
	if(visit[tempx]!=1)dfs(tempx);
	else if(start_time[tempx]<=start_time[node]&&end_time[tempx]>=end_time[node]){
		end_time[node]=curr_time;
		y[node]=-1;
		return 0;
	}
	end_time[node]=curr_time;
	if(y[tempx]==-1){
		y[node]=-1;
		return 0;
	}
	tempy+=y[tempx];
	y[node]=tempy;
	return 0;
}
int main()
{
    lld i,j;
    is(n);
    up(1,n,i)is(a[i+1]),end_time[i]=mymin;
    up(2,n+1,i)
    {
    	if(visit[i]==0)dfs(i);
    }
    visit[1]=1;
    y[1]=-1;
    up(1,n,i)
    {
    	lld tempx=1+i-a[i+1],tempy=i+a[i+1];
    	dg(tempx);
    	if(tempx<=0||tempx>n)
    	{
    		pp(tempy);
    	}
    	else if(y[tempx]!=-1)
    		pp(y[tempx]+tempy);
    	else
    		ps("-1\n");
    }
    return 0;
}


#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define ipp(n) printf("%d\n",n)
#define pp(n) printf("%lld\n",n)
#define pps(n) printf("%lld ",n)
#define ipps(n) printf("%d ",n)
#define all(x) x.begin(),x.end()
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define iis(n) scanf("%d",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld>
#define pi acos(-1)
#ifdef G
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<' '<<#zz<<' '<<zz<<endl;
#else
#define dg(x) ;
#define dg2(x,y) ;
#define dg3(x,y,z) ;
#define dg4(x,y,z,zz) ;
#endif
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ids(n,m) scanf("%d %d",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
#define its(n,m,k) scanf("%d %d %d",&n,&m,&k)
#define yes printf("YES\n")
#define no printf("NO\n")
#define isset(num,i) ((num&(1LL<<i))!=0)
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =2e5+10;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld ans,k,n,m,mymax=LLONG_MIN,mymin=LLONG_MAX,b,c,z,sum;
vector<lld> v[M];
lld visit[M],visit2[M];
lld x[M],y[M],a[M];
lld start_time[M],end_time[M],curr_time;
pll next(lld node)
{
	lld tempx=node+a[node],tempy=a[node];
	dg3(node,tempx,tempy);
	if(tempx>n||tempx<=0){
		return {-1,tempy};
	}
	tempy+=a[tempx];
	tempx-=a[tempx];
	return {tempx,tempy};
}
lld dfs(lld node)

{
	lld tempx,tempy;
	visit[node]=1;
	start_time[node]=curr_time++;
	pll temp=next(node);
	tempx=temp.F;
	tempy=temp.S;
	if(tempx<=0){
		y[node]=tempy;
		end_time[node]=curr_time;
		return  0;
	}
	dg3(node,tempx,tempy);
	if(visit[tempx]!=1)dfs(tempx);
	else if(start_time[tempx]<=start_time[node]&&end_time[tempx]>=end_time[node]){
		end_time[node]=curr_time;
		y[node]=-1;
		return 0;
	}
	end_time[node]=curr_time;
	if(y[tempx]==-1){
		y[node]=-1;
		return 0;
	}
	tempy+=y[tempx];
	y[node]=tempy;
	return 0;
}
int main()
{
    lld i,j;
    is(n);
    up(1,n,i)is(a[i+1]),end_time[i]=mymin;
    up(2,n+1,i)
    {
    	if(visit[i]==0)dfs(i);
    }
    visit[1]=1;
    y[1]=-1;
    up(1,n,i)
    {
    	lld tempx=1+i-a[i+1],tempy=i+a[i+1];
    	dg(tempx);
    	if(tempx<=0||tempx>n)
    	{
    		pp(tempy);
    	}
    	else if(y[tempx]!=-1)
    		pp(y[tempx]+tempy);
    	else
    		ps("-1\n");
    }
    return 0;
}


#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>
using namespace std;

#define PI 3.14159265359
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfstr(v) scanf("%s", v);
#define sz(v) (int)v.size()
#define ndl puts("")
#define SS stringstream
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int n, a[200005];

ll dp[200005][2];
int vis[200005][2];
int  cur_dfs;

ll dfs(int node, bool flag) {
	if (node > n || node <= 0) return 0;
	if (vis[node][flag] == cur_dfs) return -1;
	vis[node][flag] = cur_dfs;
	ll &ret = dp[node][flag];
	if (ret != 0) return ret;
	if(flag) ret = dfs(node + a[node], !flag);
	else ret = dfs(node - a[node], !flag);
	if (ret > -1) ret += a[node];
	return ret;
}

int main() {
	PLAY();

	cin >> n;
	for (int i = 2; i <= n; i++)
		cin >> a[i];

	for (int i = 1; i < n; i++) {
		cur_dfs++;
		a[1] = i;
		dp[1][1] = 0;
		cout << max(-1LL, dfs(1, 1)) << "\n";
	}

	return 0;
}


/// sooooop? akhe sooop vste code?! gushname! mifahmi?? :))
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 2000 * 100 + 19;
int col[maxn][3], n;
ll ans[maxn][3], A[maxn];

void dfs(int u,int t){
	col[u][t] = 1;
	if (t){
		if (A[u] + u <= n){

			if (!col[A[u] + u][0])
				dfs(A[u] + u, 0);

			if (ans[A[u] + u][0] != -1)
				ans[u][t] = 1ll * A[u] + ans[A[u] + u][0];
			else
				ans[u][t] = -1;
		}
		else
			ans[u][t] = A[u];
	}

	if (!t){
		if (u - A[u] > 0){

			if (!col[u - A[u]][1])
				dfs(u - A[u], 1);

			if (ans[u - A[u]][1] != -1)
				ans[u][t] = 1ll * A[u] + ans[u - A[u]][1];
			else
				ans[u][t] = -1;
		}
		else
			ans[u][t] = A[u];
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> n;
	for (int i = 2; i <= n; i++)
		cin >> A[i];

	for (int i = 1; i <= n - 1; i++){
		A[1] = i;
		dfs(1, 1);
		cout << ans[1][1] << endl;
	}
}


/// sooooop? akhe sooop vste code?! gushname! mifahmi?? :))
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 2000 * 100 + 19;
int col[maxn][3], n;
ll ans[maxn][3], A[maxn];

void dfs(int u,int t){
	col[u][t] = 1;
	if (t){
		if (A[u] + u <= n){
			if (!col[A[u] + u][0])
				dfs(A[u] + u, 0);
			if (ans[A[u] + u][0] > 0) ans[u][t] = A[u] + ans[A[u] + u][0];
			else ans[u][t] = -1;
		}
		else
			ans[u][t] = A[u];
	}

	if (!t){
		if (u - A[u] > 0){
			if (!col[u - A[u]][1])
				dfs(u - A[u], 1);
			if (ans[u - A[u]][1] > 0) ans[u][t] = A[u] + ans[u - A[u]][1];
			else ans[u][t] = -1;
		}
		else
			ans[u][t] = A[u];
	}

}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> n;
	for (int i = 2; i <= n; i++)
		cin >> A[i];

	for (int i = 1; i <= n - 1; i++){
		A[1] = i;
		dfs(1, 1);
		cout << ans[1][1] << endl;
	}
}


/// sooooop? akhe sooop vste code?! gushname! mifahmi?? :))
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 2000 * 100 + 19;
int col[maxn][3], n, fix[maxn][3];
ll ans[maxn][3], A[maxn];

void dfs(int u,int t){
	col[u][t] = 1;
	if (t){
		if (A[u] + u <= n){

			if (!col[A[u] + u][0])
				dfs(A[u] + u, 0);
			else if (!fix[u + A[u]][0])
				ans[u][t] = -1, ans[u + A[u]][0] = -1;

			if (fix[A[u] + u][0] and ans[A[u] + u][0] != -1)
				ans[u][t] = 1ll * A[u] + ans[A[u] + u][0];
			else
				ans[u][t] = -1;
		}
		else
			ans[u][t] = A[u];
	}

	if (!t){
		if (u - A[u] > 0){

			if (!col[u - A[u]][1])
				dfs(u - A[u], 1);
			else if (!fix[u - A[u]][1])
				ans[u][t] = -1, ans[u - A[u]][1] = -1;

			if (fix[u - A[u]][1] and ans[u - A[u]][1] != -1)
				ans[u][t] = 1ll * A[u] + ans[u - A[u]][1];
			else
				ans[u][t] = -1;
		}
		else
			ans[u][t] = A[u];
	}

	fix[u][t] = 1;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> n;
	for (int i = 2; i <= n; i++)
		cin >> A[i];

	//int i = 2;
	for (int i = 1; i <= n - 1; i++){
		A[1] = i;
		fix[1][1] = 0;
		dfs(1, 1);
		cout << ans[1][1] << endl;
	}
}


/// sooooop? akhe sooop vste code?! gushname! mifahmi?? :))
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 2000 * 100 + 19;
int col[maxn][3], n, fix[maxn][3];
ll ans[maxn][3], A[maxn];

void dfs(int u,int t){
	col[u][t] = 1;
	if (t){
		if (A[u] + u <= n){

			if (!col[A[u] + u][0])
				dfs(A[u] + u, 0);

			if (fix[A[u] + u][0] and ans[A[u] + u][0] != -1)
				ans[u][t] = 1ll * A[u] + ans[A[u] + u][0];
			else
				ans[u][t] = -1;
		}
		else
			ans[u][t] = A[u];
	}

	if (!t){
		if (u - A[u] > 0){

			if (!col[u - A[u]][1])
				dfs(u - A[u], 1);

			if (fix[u - A[u]][1] and ans[u - A[u]][1] != -1)
				ans[u][t] = 1ll * A[u] + ans[u - A[u]][1];
			else
				ans[u][t] = -1;
		}
		else
			ans[u][t] = A[u];
	}

	fix[u][t] = 1;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> n;
	for (int i = 2; i <= n; i++)
		cin >> A[i];

	for (int i = 1; i <= n - 1; i++){
		A[1] = i;
		dfs(1, 1);
		cout << ans[1][1] << endl;
	}
}


#include <fstream>
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

const long long inf = (long long)2 * 1e9;
const long long MOD = (long long)1e8;
const long long P = 239;
const long long MAX_N = 200000;
const long double pi = 3.1415926;
const long double eps = 1e-6;

long long a[MAX_N + 1];
long long ans[MAX_N + 1][2];
long long n;

void dfs(long long x, long long t)
{
    if (t == 0)
    {
        if (x + a[x] > n)
            ans[x][0] = a[x];
        else
        {
            if (ans[x + a[x]][1] == 0)
            {
                ans[x][0] = -2;
                dfs(x + a[x], 1);
            }
            if (ans[x + a[x]][1] == -1 || ans[x + a[x]][1] == -2)
                ans[x][0] = -1;
            else
                ans[x][0] = ans[x + a[x]][1] + a[x];
        }
    }
    if (t == 1)
    {
        if (x - a[x] < 1)
            ans[x][1] = a[x];
        else
        {
            if (ans[x - a[x]][0] == 0)
            {
                ans[x][1] = -2;
                dfs(x - a[x], 0);
            }
            if (ans[x - a[x]][0] == -1 || ans[x - a[x]][0] == -2)
                ans[x][1] = -1;
            else
                ans[x][1] = ans[x - a[x]][0] + a[x];
        }
    }
}

int main()
{
    //ifstream ifs("input.in");
    //ofstream ofs("output.out");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (long long i = 2; i <= n; i++)
        cin >> a[i];
    for (long long i = 1; i <= n; i++)
    {
        ans[i][0] = 0;
        ans[i][1] = 0;
    }
    ans[1][0] = -1;
    ans[1][1] = 0;
    for (long long i = 2; i <= n; i++)
    {
        if (ans[i][0] == 0)
            dfs(i, 0);
        if (ans[i][1] == 0)
            dfs(i, 1);
    }
    for (long long i = 1; i < n; i++)
        cout << (ans[i + 1][1] != -1 ? ans[i + 1][1] + i : -1) << endl;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;
void Emsawy(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);   // don't use scanf & printf
	cin.tie(0);
	cout.tie(0);
}

#define p00          point(0,0)
#define O            const point &
#define CD           const double &
#define EQ(a, b)     (fabs((a) - (b)) <= eps) /* equal to */
#define LT(a, b)     ((a) < (b)-eps) /* less than */
#define sz(v)	     ((int)((v).size()))
#define all(v)	     ((v).begin()), ((v).end())
#define allr(v)	     ((v).rbegin()), ((v).rend())
#define clr(v,d)     memset(v, d, sizeof(v))
#define length(a)    (hypot((a).imag(), (a).real()))
#define dp(a,b)	     ((conj(a)*(b)).real()) // if zero prep
#define cp(a,b)	     ((conj(a)*(b)).imag()) // if zero parl
#define pii	         pair<int,int>
#define V	         vector
#define MP	         make_pair
#define bug(n)           cout<< #n <<" = "<< n << endl;

typedef long long ll;

const double PI = acos(-1.0);
const double eps = 1e-10;
const ll mod = 1e9 + 7, oo = 1e9;

int dx[]{1, -1, 0, 0, 1, -1, 1, -1};
int dy[]{0, 0, 1, -1, 1, -1, -1, 1};

V<V<pii> > adj;
int n, m, k, t, c;
const int N = 200000 + 5;
int v[N];
ll dp[N][2];

ll go(int id, bool ok = 1){
	if (id + v[id] >= 1 && id + v[id] <= n && (id + v[id]) - v[id + v[id]] == id) return -oo;
	if (id <= 0 || id > n) return 0;
	ll &ret = dp[id][ok];
	if (ret != -1) return ret;
	ret = 0;
	if(ok) ret += go(id + v[id],!ok) + v[id];
	else ret += go(id - v[id],!ok) + v[id];
	return ret;
}
int main()
{
	Emsawy();
	while (cin >> n){
		for (int i = 2; i <= n; i++)
			cin >> v[i];
		clr(dp, -1);
		for (int i = 1; i < n; i++){
			dp[1][1] = -1;
			v[1] = i;
			ll ret = go(1);
			if (ret < 0) ret = -1;
			cout << ret << endl;
		}
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;
void Emsawy(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);   // don't use scanf & printf
	cin.tie(0);
	cout.tie(0);
}

#define p00          point(0,0)
#define O            const point &
#define CD           const double &
#define EQ(a, b)     (fabs((a) - (b)) <= eps) /* equal to */
#define LT(a, b)     ((a) < (b)-eps) /* less than */
#define sz(v)	     ((int)((v).size()))
#define all(v)	     ((v).begin()), ((v).end())
#define allr(v)	     ((v).rbegin()), ((v).rend())
#define clr(v,d)     memset(v, d, sizeof(v))
#define length(a)    (hypot((a).imag(), (a).real()))
#define dp(a,b)	     ((conj(a)*(b)).real()) // if zero prep
#define cp(a,b)	     ((conj(a)*(b)).imag()) // if zero parl
#define pii	         pair<int,int>
#define V	         vector
#define MP	         make_pair
#define bug(n)           cout<< #n <<" = "<< n << endl;

typedef long long ll;

const double PI = acos(-1.0);
const double eps = 1e-10;
const ll mod = 1e9 + 7, oo = 1e16;

int dx[]{1, -1, 0, 0, 1, -1, 1, -1};
int dy[]{0, 0, 1, -1, 1, -1, -1, 1};

V<V<pii> > adj;
int n, m, k, t, c;
const int N = 200000 + 5;
int v[N];
ll dp[N][2];

ll go(int id, bool ok = 1){
	if (id <= 0 || id > n) return 0;
	ll &ret = dp[id][ok];
	if (ret != -1) return ret = (ret == 0 ? -oo : ret);
	ret = 0;
	if(ok) ret += go(id + v[id],!ok) + v[id];
	else ret += go(id - v[id],!ok) + v[id];
	return ret;
}
int main()
{
	Emsawy();
	while (cin >> n){
		for (int i = 2; i <= n; i++)
			cin >> v[i];
		clr(dp, -1);
		for (int i = 1; i < n; i++){
			dp[1][1] = -1;
			v[1] = i;
			ll ret = go(1);
			if (ret < 0) ret = -1;
			cout << ret << endl;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%I64d",&x)
#define ss(s)	scanf("%s",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;
const int N = 2e5+3;
vi g[N];
int a[N];
ll dp[2][N]; int vis[2][N];
int n;
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);
const ll ninf = -1e16;
ll go(int turn, int pos, int key){
	if (pos<=0 or pos>n) return 0;
	if (vis[turn][pos] == key) return ninf;
	vis[turn][pos] = key;
	ll &ans = dp[turn][pos]; if (ans!=-1 and pos != 1) return ans;
	if(!turn){
		//add
		return ans = a[pos]+go(1-turn, pos+a[pos], key);
	}
	else{
		//subtract
		return ans = a[pos]+go(1-turn, pos-a[pos], key);
	}
}
int main()
{
	int i;
	si(n);
	fo(i, N) dp[0][i] = dp[1][i] = vis[0][i] = vis[1][i] = -1;
	fo(i, n-1) si(a[i+2]);
	fo(i, n-1){
		a[1] = i+1;
		printf("%I64d ",max(-1LL, go(0, 1, i+1)));
	}

	return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}


#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%I64d",&x)
#define ss(s)	scanf("%s",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;
const int N = 2e5+3;
vi g[N];
int a[N];
ll dp[2][N]; int vis[2][N];
int n;
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);
const ll ninf = -1e16;
ll go(int turn, int pos, int key){
	if (pos<=0 or pos>n) return 0;
	if (vis[turn][pos] == key) return ninf;
	vis[turn][pos] = key;
	ll &ans = dp[turn][pos]; if (ans!=-1 and pos != -1) return ans;
	if(!turn){
		//add
		return a[pos]+go(1-turn, pos+a[pos], key);
	}
	else{
		//subtract
		return a[pos]+go(1-turn, pos-a[pos], key);
	}
}
int main()
{
	int i;
	si(n);
	fo(i, N) dp[0][i] = dp[1][i] = vis[0][i] = vis[1][i] = -1;
	fo(i, n-1) si(a[i+2]);
	fo(i, n-1){
		a[1] = i+1;
		printf("%I64d ",max(-1LL, go(0, 1, i+1)));
	}

	return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}


#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%I64d",&x)
#define ss(s)	scanf("%s",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;
const int N = 2e5+3;
vi g[N];
int a[N];
ll dp[2][N]; int vis[2][N];
int n;
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);
const ll ninf = -1e16;
ll go(int turn, int pos, int key){
	if (pos<=0 or pos>n) return 0;
	if (vis[turn][pos] == key) return ninf;
	vis[turn][pos] = key;
	ll &ans = dp[turn][pos]; if (ans!=-1 and pos != -1) return ans;
	if(!turn){
		//add
		return a[pos]+go(1-turn, pos+a[pos], key);
	}
	else{
		//subtract
		return a[pos]+go(1-turn, pos-a[pos], key);
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i;
	si(n);
	fo(i, N) dp[0][i] = dp[1][i] = vis[0][i] = vis[1][i] = -1;
	fo(i, n-1) si(a[i+2]);
	fo(i, n-1){
		a[1] = i+1;
		cout<<max(-1LL, go(0, 1, i+1))<<endl;
	}

	return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}


#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%I64d",&x)
#define ss(s)	scanf("%s",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;
const int N = 2e5+3;
vi g[N];
int a[N];
ll dp[2][N]; int vis[2][N];
int n;
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);
int go(int turn, int pos, int key){
	if (pos<=0 or pos>n) return 0;
	if (vis[turn][pos] == key) return -1;
	vis[turn][pos] = key;
	ll &ans = dp[turn][pos]; if (ans!=-1 and pos != -1) return ans;
	if(!turn){
		//add
		return a[pos]+go(1-turn, pos+a[pos], key);
	}
	else{
		//subtract
		return a[pos]+go(1-turn, pos-a[pos], key);
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i;
	si(n);
	fo(i, N) dp[0][i] = dp[1][i] = vis[0][i] = vis[1][i] = -1;
	fo(i, n-1) si(a[i+2]);
	fo(i, n-1){
		a[1] = i+1;
		cout<<go(0, 1, i+1)<<endl;
	}

	return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}


#include <bits/stdc++.h>

using namespace std;

typedef double de;
typedef long long int LL;
const int N = 200100;

int n;
int a[N];
LL d[N][2];
int vis[N][2];
int pre[N][2];
bool viss;

LL dfs ( int x, int ot ) {
	if (x <= 0 || x > n)
		return 0;
	if (d[x][ot])
		return d[x][ot];
	if (vis[x][ot])
		return -1;
	if (pre[x][ot])
		viss = true;

	vis[x][ot] = 1;
	if (!ot) {
		LL tmp = dfs( x + a[x], 1 );
		if (x + a[x] >= 1 && x + a[x] <= n)
			pre[x][ot] |= pre[x + a[x]][ot ^ 1];
		if (tmp >= 0)
			d[x][ot] = dfs( x + a[x], 1 ) + a[x];
		else
			d[x][ot] = -1;
	}
	else {
		LL tmp = dfs( x - a[x], 0 );
		if (x - a[x] >= 1 && x + a[x] <= n)
			pre[x][ot] |= pre[x - a[x]][ot ^ 1];
		if (tmp >= 0)
			d[x][ot] = dfs( x - a[x], 0 ) + a[x];
		else
			d[x][ot] = -1;
	}
	return d[x][ot];
}

int main ( ) {
#ifndef ONLINE_JUDGE
	freopen("A.in", "r", stdin);
	freopen("A.out", "w", stdout);
#endif

	scanf("%d", &n);

	for (int i = 2;i <= n; ++i)
		scanf("%d", &a[i]);

	pre[1][1] = 1;
	for (int i = 1;i < n; ++i) {
		a[1] = i, viss = false;
		d[1][0] = d[1][1] = 0;
		vis[1][0] = vis[1][1] = 0;
		printf("%lld\n", dfs( 1, 0 ) + (viss ? (i - 1) : 0));
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef double de;
typedef long long int LL;
const int N = 100100;

int n;
int a[N];
LL d[N][2];
int vis[N][2];
int pre[N][2];
bool viss;

LL dfs ( int x, int ot ) {
	if (x <= 0 || x > n)
		return 0;
	if (d[x][ot])
		return d[x][ot];
	if (vis[x][ot])
		return -1;
	if (pre[x][ot])
		viss = true;

	vis[x][ot] = 1;
	if (!ot) {
		LL tmp = dfs( x + a[x], 1 );
		if (x + a[x] >= 1 && x + a[x] <= n)
			pre[x][ot] |= pre[x + a[x]][ot ^ 1];
		if (tmp >= 0)
			d[x][ot] = dfs( x + a[x], 1 ) + a[x];
		else
			d[x][ot] = -1;
	}
	else {
		LL tmp = dfs( x - a[x], 0 );
		if (x - a[x] >= 1 && x + a[x] <= n)
			pre[x][ot] |= pre[x - a[x]][ot ^ 1];
		if (tmp >= 0)
			d[x][ot] = dfs( x - a[x], 0 ) + a[x];
		else
			d[x][ot] = -1;
	}
	return d[x][ot];
}

int main ( ) {
#ifndef ONLINE_JUDGE
	freopen("A.in", "r", stdin);
	freopen("A.out", "w", stdout);
#endif

	scanf("%d", &n);

	for (int i = 2;i <= n; ++i)
		scanf("%d", &a[i]);

	pre[1][1] = 1;
	for (int i = 1;i < n; ++i) {
		a[1] = i, viss = false;
		d[1][0] = d[1][1] = 0;
		vis[1][0] = vis[1][1] = 0;
		printf("%lld\n", dfs( 1, 0 ) + (viss ? (i - 1) : 0));
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair

bool vis[200005][2];
long long v2[200005][2];
bool v3[200005][2];
int v[200005];
int n;

long long bfs(int x, int e){
	if(x <= 0 || x > n)
		return 0;
	if(x == 1){
		if(e == 1)
			return -2;
		else
			return -1;
	}
	if(vis[x][e]){
		if(v2[x][e] == 0) return -1;
		return v2[x][e];
	}

	vis[x][e] = 1;

	long long a;

	if(e)
		a = bfs(x - v[x], !e);
	else
		a = bfs(x + v[x], !e);
	if(a == -1)
		return v2[x][e] = -1;
	if(a == -2){
		v3[x][e] = 1;
		return v2[x][e] = v[x];
	}
	return v2[x][e] = a + v[x];

}

int main(){
	scanf("%d",&n);
	for(int i = 0; i < n-1; i++)
		scanf("%d",v+i+2);

	for(int i = 2; i <= n; i++){
		if(!vis[i][0])
			bfs(i,0);

		if(!vis[i][1])
			bfs(i,1);
	}

	for(int i = 1; i < n; i++){
		long long ans = bfs(i+1,1);
		if(ans == -1)
			printf("-1\n");
		else{
			if(v3[i+1][1])
				printf("%lld\n",ans + 2*i);
			else
				printf("%lld\n",ans + i);
		}
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair

bool vis[200005][2];
long long v2[200005][2]
int v[200005];
int n;

long long bfs(int x, int e){
	if(x <= 0 || x > n)
		return 0;
	if(x == 1)
	    return -1;
	}
	if(vis[x][e]){
		if(v2[x][e] == 0) return -1;
		return v2[x][e];
	}

	vis[x][e] = 1;

	long long a;

	if(e)
		a = bfs(x - v[x], !e);
	else
		a = bfs(x + v[x], !e);
	if(a == -1)
		return v2[x][e] = -1
	return v2[x][e] = a + v[x];

}

int main(){
	scanf("%d",&n);
	for(int i = 0; i < n-1; i++)
		scanf("%d",v+i+2);

	for(int i = 2; i <= n; i++){
		if(!vis[i][0])
			bfs(i,0);

		if(!vis[i][1])
			bfs(i,1);
	}

	for(int i = 1; i < n; i++){
		long long ans = bfs(i+1,1);
		if(ans == -1)
			printf("-1\n");
		else{
		    printf("%lld\n",ans + i);
		}
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair

int vis[200005][2];
long long v2[200005][2];
long long v3[200005][2];
int v[200005];
int n;

long long bfs(int x, int e){
	//printf("i %d %d\n",v[x],x);
	if(x <= 0 || x > n)
		return 0;
	if(x == 1){
		if(e == 1)
			return -2;
		else
			return -1;
	}
	if(vis[x][e]){
		if(v2[x][e] == 0) return -1;
		return v2[x][e];
	}

	vis[x][e] = 1;

	int a;

	if(e)
		a = bfs(x - v[x], !e);
	else
		a = bfs(x + v[x], !e);

	//printf("r %d %d\n",x,a );
	if(a == -1)
		return v2[x][e] = -1;
	if(a == -2){
		v3[x][e] = 1;
		return v2[x][e] = v[x];
	}
	return v2[x][e] = a + v[x];

}

int main(){
	scanf("%d",&n);
	for(int i = 0; i < n-1; i++)
		scanf("%d",v+i+2);

	for(int i = 2; i <= n; i++){
		if(!vis[i][0]){
			bfs(i,0);
			//printf("a %d %lld\n",i,v2[i][0]);
		}
		if(!vis[i][1]){
			bfs(i,1);
			//printf("c %d %lld\n",i,v2[i][1]);
		}
	}

	for(int i = 1; i < n; i++){
		long long ans = bfs(i+1,1);
		if(ans == -1)
			printf("-1\n");
		else{
			if(v3[i+1][1])
				printf("%lld\n",ans + 2*i);
			else
				printf("%lld\n",ans + i);
		}
	}
	return 0;
}