from scipy.special import comb, perm
n,m=map(int,input().split())
num = input().split(" ")
ans=1;
for i in range(0,m):
ans*=comb(int(n),int(num[i]))
ans%=10007
n-=int(num[i])
print(int(ans))
ZnJvbSBzY2lweS5zcGVjaWFsIGltcG9ydCBjb21iLCBwZXJtCm4sbT1tYXAoaW50LGlucHV0KCkuc3BsaXQoKSkKbnVtID0gaW5wdXQoKS5zcGxpdCgiICIpCmFucz0xOwpmb3IgaSBpbiByYW5nZSgwLG0pOgoJYW5zKj1jb21iKGludChuKSxpbnQobnVtW2ldKSkKCWFucyU9MTAwMDcKCW4tPWludChudW1baV0pCnByaW50KGludChhbnMpKQ==