#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } constexpr long long MAX = 5100000; constexpr long long INF = 1LL << 60; constexpr int inf = 1 << 28; constexpr long long mod = 1000000007LL; //constexpr long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ ll N, K; scanf("%lld %lld", &N, &K); vector p(N); for (int i = 0; i < N; i++) scanf("%lld", &p[i]); vector> t(40, vector(N)); vector> t2(40, vector(N)); for (ll i = 0; i < N; i++) { t[0][i] = (i + p[i]) % N; if (i + p[i] >= N) { t2[0][i] = 1; //cout << i << endl; } } for (ll i = 0; i < 39; i++) { for (ll j = 0; j < N; j++) { t[i + 1][j] = t[i][t[i][j]]; t2[i + 1][j] = t2[i][t[i][j]] + t2[i][j]; } } for (ll start = 0; start < N; start++) { ll now = start; ll cnt = 0; for (ll i = 0; i < 40; i++) { if ((K >> i) & 1) { cnt += t2[i][now]; now = t[i][now]; } } printf("%lld\n", now + cnt * N + 1); } return 0; }