mod = 10 ** 9 + 7 def solve(): N, K = map(int, input().split()) A = list(map(int, input().split())) if K <= 10 ** 6: sol1(N, K, A) else: sol2(N, K, A) def mul(a, b): l = len(a) c = [[0] * l for i in range(l)] for i in range(l): ai = a[i] for k in range(l): bk = b[k] for j in range(l): c[i][j] += ai[k] * bk[j] if c[i][j] > mod: c[i][j] %= mod return c def mpow(a, n): if n == 1: return a c = mpow(mul(a, a), n // 2) if n % 2 == 0: return c else: return mul(a, c) def sol2(N, K, A): fmat = [[0] * (N) for i in range(N)] for i in range(N - 1): fmat[i + 1][i] = 1 for i in range(N): fmat[0][i] = 1 fmat = mpow(fmat, K - N) fk = 0 for i in range(N): fk += fmat[0][i] * A[N - i - 1] fk %= mod smat = [[0] * (N + 1) for i in range(N + 1)] smat[0][0] = 2 smat[0][N] = -1 for i in range(N): smat[i + 1][i] = 1 smat = mpow(smat, K - N) S = [0] * (N + 1) for i in range(1, N + 1): S[i] = sum(A[:i]) sk = 0 for i in range(N + 1): sk += smat[0][i] * S[N - i] sk %= mod print(fk, sk) def sol1(N, K, A): dp = [0] * (K + 1) for k in range(K + 1): if k <= N: dp[k] = sum(A[:k]) % mod else: dp[k] = (dp[k - 1] + dp[k - 1] - dp[k - N - 1]) % mod print(dp[K - 1] - dp[K - N - 1], dp[K]) if __name__ == '__main__': solve()