MOD = 10 ** 9 + 7 n, m = map(int, input().split()) A = list(map(int, input().split())) ans = sum(A) % MOD times = [m - 1] i = m j = 2 for _ in range(n - 2): times.append(times[-1] * i * pow(j, MOD - 2, MOD) % MOD) i += 1 j += 1 A = A[::-1] for i in range(1, n - 1): times[i] += times[i - 1] for a, t in zip(A, times): ans += a * t ans %= MOD print(ans)