ll@n,a[40][1d5]{},q;rd(a[0](n),q);rep(i,39)rep(j,n)a[i+1][j]=a[i][j]+a[i][(j+a[i][j])%n];rep(q){ll@k,r=0;rep(i,40)r+=k>>i&1?a[i][r%n]:0;wt(r);}