N, K = map(int, input().split()) P = list(map(int, input().split())) M = 35 dp = [[0] * N for _ in range(M)] for i in range(N): dp[0][i] = i + P[i] for n in range(1, M): for i in range(N): dp[n][i] = dp[n - 1][dp[n - 1][i] % N] + dp[n - 1][i] // N * N for i in range(N): now = i ans = i + 1 for j in range(M): if (K >> j) & 1: ans += dp[j][now % N] - now % N now = dp[j][now % N] print(ans)