mod = 10**9+7 k, n = map(int, input().split()) a = list(map(int, input().split())) # 累積和 if n <= 10**6: aa = [0]*n # 1-indexed s = [0]*(n+1) for i in range(k): aa[i] = a[i] s[i+1] = s[i] + a[i] for i in range(k, n): ai = s[i] - s[i-k] aa[i] = ai aa[i] %= mod s[i+1] = s[i] + ai s[i+1] %= mod print(aa[-1], s[-1]) # 行列累乗 else: def mul(a, b): n = len(a) c = [[0]*n for i in range(n)] for i in range(n): for j in range(n): for k in range(n): c[i][j] += (a[i][k]*b[k][j])%mod return c def pow(a, n): b = [[0]*len(a) for i in range(len(a))] for i in range(len(a)): b[i][i] = 1 while n: if n&1: b = mul(a, b) a = mul(a, a) n >>=1 return b A = [[0]*k for i in range(k)] A[0] = [1]*k for i in range(k-1): A[i+1][i] = 1 A = pow(A, n-k) f = 0 for i in range(k): f += A[0][i]*a[k-i-1] f %= mod B = [[0]*(k+1) for i in range(k+1)] B[0][0] = 2 B[0][-1] = -1 for i in range(k): B[i+1][i] = 1 B = pow(B, n-k) from itertools import accumulate s = [0] + list(accumulate(a)) g = 0 for i in range(k+1): g += B[0][i]*s[k-i] g %= mod print(f, g)