#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
const int maxn = 100010;
ll num[maxn];
ll inv(ll t, ll p = mod)
{//求t关于p的逆元,注意:t要小于p,最好传参前先把t%p一下
return t == 1 ? 1 : (p - p / t) * inv(p % t, p) % p;
}
ll pow(ll x, ll n)
{
ll ans = 1;
for (; n;n>>=1, x=x*x%mod)
if (n & 1)ans = ans*x%mod;
return ans;
}
int main()
{
ll n, m;
scanf("%lld%lld", &n, &m);
for (int i = 1; i <= m; ++i)
scanf("%lld", &num[i]);
sort(num + 1, num + m+1);
ll ans = 0;
for (int i = 1; i <= m; ++i)
{
ll a0 = ((i - 1)*n + 1)%mod, an = i*n%mod;
ll A = (a0 + an) % mod*n%mod*inv(2)%mod, X;
num[i] %= mod;
if (num[i] == 0)X = 1;
else if (num[i] == 1)X = n;
else {
X = (pow(num[i], n) - 1) % mod*inv(num[i] - 1) % mod;
}
ans = (ans + X*A%mod) % mod;
}
printf("%lld
", ans);
}