n,c = map(int,input().split()) a = list(map(int,input().split())) from collections import defaultdict d = defaultdict(int) for i in a: d[i] += 1 P = 10 ** 9 + 7 ans = 0 for i in d: inv = pow(i,P-2,P) u = 1 for j in d: if j == i:continue t = (1 - j * inv) % P t = pow(t,P-2,P) t = pow(t,d[j],P) u = u * t % P v = pow(i,c,P) ans += (u - d[i]) * v ans %= P print(ans)