import sys input = sys.stdin.readline N = int(input()) x = list(map(int, input().split())) MOD = 10**9+7 S = sum(x)%MOD T = sum(xi**2%MOD for xi in x)%MOD ans = (S*S-T)*(S-1)*pow(S*(S-1), MOD-2, MOD)%MOD ans = (ans+1)%MOD print(ans)