#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines MOD = 10 ** 9 + 7 def solve_1(N, K, A): S = [0] * (K + 1) for i, x in enumerate(A, 1): S[i] = S[i - 1] + x for n in range(N + 1, K + 1): S[n] = 2 * S[n - 1] - S[n - N - 1] S[n] %= MOD return (S[K] - S[K - 1]) % MOD, S[K] N, K, *A = map(int, read().split()) print(*solve_1(N, K, A))