/** * @FileName a.cpp * @Author kanpurin * @Created 2020.09.30 19:17:42 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { int n,k;cin >> n >> k; vector p(n); for (int i = 0; i < n; i++) { cin >> p[i]; } vector> next_v(32,vector(n)); vector> sum(32,vector(n)); for (int i = 0; i < n; i++) { next_v[0][i] = (i+p[i])%n; sum[0][i] = p[i]; } for (int i = 1; i < 32; i++) { for (int j = 0; j < n; j++) { next_v[i][j] = next_v[i-1][next_v[i-1][j]]; sum[i][j] = sum[i-1][j] + sum[i-1][next_v[i-1][j]]; } } for (int i = 0; i < n; i++) { ll now = i; ll ans = i+1; for (int j = 0; j < 32; j++) { if (k & (1<