n,k = map(int,input().split())
a = [int(i) for i in input().split()]

b = []
for i in range(n):
    b.append(0)
for i in range(k):
    b.sort()
    for j in range(a[i]):
        b[j] += 1

w = pow(10, 9) + 7
c = 1
for i in range(n):
    c *= b[i]
    c %= w
tmp = 1
for i in range(0, k-1, 2):
    tmp *= n * (-a[i+1] + a[i])
    tmp %= w
print(c, c * tmp % w)