N, K = map(int, input().split()) A = list(map(int, input().split())) m = 1000000007 if K == 0: result = 0 for a in A: result += a result %= m print(result)