Given are N integers A_1,\ldots,A_N.
Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

-----Constraints-----
 - 2 \leq N \leq 2\times 10^5
 - 0 \leq A_i \leq 10^9
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
A_1 \ldots A_N

-----Output-----
Print \sum_{i=1}^{N-1}\sum_{j=i+1}^{N} A_i A_j, modulo (10^9+7).

-----Sample Input-----
3
1 2 3

-----Sample Output-----
11

We have 1 \times 2 + 1 \times 3 + 2 \times 3 = 11.
[{"code": "def main():\n   N=int(input())\n   CONST= 10**9+7\n   Output = 0\n   lis = list(map(int,input().split()))       \n   lis.sort()\n   SumLis = [0]*N\n   for i,item in enumerate(lis):\n      SumLis[i] += SumLis[i-1]+item\n   for i,item in enumerate(lis):\n      Output += lis[i] * (SumLis[-1]-SumLis[i])\n      Output %= CONST\n   print(Output)\n\n      \ndef __starting_point():\n    main()\n\n\n__starting_point()", "passed": true, "time": 0.36, "memory": 14308.0, "status": "done"}, {"code": "def cumsum(xs):\n  result = [xs[0]]\n  for x in xs[1:]:\n    result.append(result[-1] + x)\n  return result\n\nN = int(input())\nA = list(map(int, input().split()))\n\nans = 0\nMOD = 10**9 + 7\nA.reverse()\nruisekiwa = cumsum(A)\nruisekiwa.reverse()\nA.reverse()\n\nfor i in range(N-1):\n        ans = (ans + A[i] * ruisekiwa[i+1]) % MOD\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14324.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\ns = [0]\nfor i in range(n):\n\ts.append(s[i] + a[i])\nans = sum(a[i] * (s[n]-s[i+1]) for i in range(n))\nprint(ans % (10**9 + 7))", "passed": true, "time": 0.15, "memory": 14056.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nmod = 10**9 + 7\ns = sum(a)\nans = 0\n\nfor x in a:\n  s -= x\n  ans += s * x\n  \nprint(ans%mod)", "passed": true, "time": 0.28, "memory": 14252.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nA2 = [A[0]]\nmod = 10 ** 9 + 7\nres = 0\nfor i in range(1, N):\n  A2.append((A2[i-1] + A[i]) % mod)\nfor i in range(N-1):\n  res = (res + A[i] * (A2[N-1] - A2[i])) % mod\nprint(res)", "passed": true, "time": 0.32, "memory": 14104.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nmod = 10**9 + 7\nans = 0\ns = sum(a)\n\nfor x in a:\n  s -= x\n  ans += s * x\n  ans %= mod\n  \nans %= mod\nprint(ans)", "passed": true, "time": 0.36, "memory": 14104.0, "status": "done"}, {"code": "CONST = 10 ** 9 + 7\nN = int(input())\nnumbers = list(map(int, input().split()))\nr = 0\n\n\ndef cumsum(xs):\n    result = []\n    for i in range(len(xs)):\n        if i == 0:\n            result.append(xs[0])\n        else:\n            result.append(result[-1] + xs[i])\n    return result\n\n\nnumbers.reverse()\nnum_sum = cumsum(numbers)\nnum_sum.reverse()\nnumbers.reverse()\ndel num_sum[0]\nfor i in range(N-1):\n    r += (numbers[i]*num_sum[i])%CONST\nprint((r % CONST))\n", "passed": true, "time": 0.14, "memory": 14300.0, "status": "done"}, {"code": "import math\nprime = [True for i in range(10**6+1)]\ndef SieveOfEratosthenes(n): \n\tp = 2\n\twhile (p * p <= n): \n\t\tif (prime[p] == True):\n\t\t\tfor i in range(p * p, n+1, p): \n\t\t\t\tprime[i] = False\n\t\tp += 1\n\ndef __starting_point():\n\tN = int(input())\n\tL = list(map(int,input().split()))\n\tMOD =  10**9 + 7\n\tsum_L = sum(L)\n\tans = 0\n\tfor i in range(N - 1):\n\t\tsum_L = sum_L - L[i]\n\t\tans = (ans + sum_L*L[i])%MOD\n\tprint(ans)\n\n\n\n\n\n__starting_point()", "passed": true, "time": 0.3, "memory": 21276.0, "status": "done"}, {"code": "import math\nprime = [True for i in range(10**6+1)]\ndef SieveOfEratosthenes(n): \n\tp = 2\n\twhile (p * p <= n): \n\t\tif (prime[p] == True):\n\t\t\tfor i in range(p * p, n+1, p): \n\t\t\t\tprime[i] = False\n\t\tp += 1\n\ndef __starting_point():\n\tN = int(input())\n\tL = list(map(int,input().split()))\n\tMOD =  10**9 + 7\n\tsum_L = sum(L)\n\tans = 0\n\tfor i in range(N - 1):\n\t\tsum_L = sum_L - L[i]\n\t\tans = (ans + sum_L*L[i])%MOD\n\tprint(ans)\n\n\n\n\n3\n__starting_point()", "passed": true, "time": 0.33, "memory": 21396.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nmod = 10**9+7\n\n# result = 0\n# for i in range(N):\n#     for j in range(N):\n#         if i < j:\n#             result += (A[i] * A[j]) % mod\n\n# print(result % mod)\n\n# result = 0\n# for i in range(N):\n#     j = i+1\n\n#     while(j < N):\n#         result += (A[i] * A[j]) % mod\n#         #print(i, \" : \", j)\n#         j += 1\n\n# print(result % mod)\n\nA_sum = sum(A)\nresult = 0\nfor i in range(N):\n    A_sum = A_sum - A[i]\n    result += (A[i] * A_sum) % mod\n\nprint(result % mod)", "passed": true, "time": 0.3, "memory": 14184.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\ns = [0]\nfor i in range(n):\n\ts.append(s[i] + a[i])  # \u7d2f\u7a4d\u548c\nans = sum(a[i] * (s[n]-s[i+1]) for i in range(n))\nprint(ans % (10**9 + 7))", "passed": true, "time": 0.14, "memory": 14044.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\ns = 0\ns2 = sum(A)\n\nfor i in range(N-1):\n    s2 -= A[i]\n    s += A[i] * s2\n\nanswer = s % (10**9+7)\nprint(answer)", "passed": true, "time": 0.26, "memory": 14212.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nsuma = sum(a)\nc = 0\nfor num in a:\n  c += num**2\nprint((suma**2-c)//2%(10**9+7))", "passed": true, "time": 0.15, "memory": 14180.0, "status": "done"}, {"code": "n = int(input().strip())\nl = list(map(int,input().strip().split()))\ns = sum(l)\nans=0\nMOD=1000000007\nfor i in range(n-1):\n\tans+=l[i]*(s-l[i])\n\ts-=l[i]\n\t\nprint((ans%MOD))\n\t\n", "passed": true, "time": 0.15, "memory": 14216.0, "status": "done"}, {"code": "mod = 10**9 + 7\nn = int(input())\nl = list(map(int,input().split()))\nsum_l = sum(l)\nans = 0\nfor i in range(n):\n  sum_l -= l[i]\n  ans += sum_l * l[i]\nprint(ans%mod)", "passed": true, "time": 0.14, "memory": 14044.0, "status": "done"}, {"code": "CONST = 10 ** 9 + 7\nN = int(input())\nnumbers = list(map(int, input().split()))\nr = 0\n\n\ndef cumsum(xs):\n    result = []\n    for i in range(len(xs)):\n        if i == 0:\n            result.append(xs[0])\n        else:\n            result.append(result[-1] + xs[i])\n    return result\n\n\nnumbers.reverse()\nnum_sum = cumsum(numbers)\nnum_sum.reverse()\nnumbers.reverse()\ndel num_sum[0]\nfor i in range(N-1):\n    r += (numbers[i]*num_sum[i])%CONST\nprint((r % CONST))\n", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "n = int(input())\narr = input()\nar = list(map(int,arr.split(' ')))\nsum=0\ns=0\nmod=1000000007\nfor i in range(0,n):\n    sum=sum+(ar[i]*ar[i])\n    s=s+ar[i]\ns=s*s\nprint(((s-sum)//2)%mod)", "passed": true, "time": 0.26, "memory": 14220.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nprint((sum(A)**2-sum(a**2 for a in A))//2%(10**9+7))", "passed": true, "time": 0.15, "memory": 14232.0, "status": "done"}, {"code": "n = int(input())\nA = [int(x) for x in input().split()]\nmod = 10**9+7\na_cum = [0] * (n+1)\n# \u7d2f\u7a4d\u548c\u306e\u8a08\u7b97\nfor i in range(n):\n    a_cum[i + 1] = a_cum[i] + A[i]\nans = 0\nfor i in range(len(A)-1):\n    # a_cum[n]\u306f\u5168\u3066\u306e\u5408\u8a08\u3068\u540c\u7fa9\u3002a_cum\u306findex\u304c1\u3064\u305a\u308c\u3066\u3044\u308b\u306e\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b\u3002 \n    ans += A[i] * (a_cum[n] - a_cum[i+1]) % mod\nans %= mod\nprint(ans)", "passed": true, "time": 0.16, "memory": 14192.0, "status": "done"}, {"code": "n=int(input())\nalst=list(map(int,input().split()))\nmod=10**9+7\n\nlst_sm=sum(alst)\nsm=lst_sm**2\nfor i in range(n):\n    sm-=alst[i]**2\nsm//=2\nprint((sm%mod))\n", "passed": true, "time": 0.14, "memory": 14360.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nmod = 10 ** 9 + 7\nans = 0\ntotal = sum(a)\nfor i in range(n):\n    total -= a[i]\n    ans = (ans + total * a[i]) % mod\n\nprint(ans)", "passed": true, "time": 0.15, "memory": 14256.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\ns = sum(a)\nans = 0\nsub = 0\n\nfor i in range(n):\n  ans += a[i]*s\n  \nfor j in range(n):\n  sub += a[j]**2\n    \nprint(((ans-sub)//2)%(10**9 + 7))", "passed": true, "time": 0.15, "memory": 14308.0, "status": "done"}, {"code": "def cusum(a):\n    cusum = [a[0]]\n    for i in range(len(a)-1):\n        cusum.append(cusum[i] + a[i+1])\n    return cusum\n\n\ndef solve1(n, a):\n    ans = 0\n    mod = 10**9 + 7\n    cusum_a = cusum(a)\n\n    for i in range(n):\n        ans += a[i] * (cusum_a[-1] - cusum_a[i])\n        \"\"\"\n        print(a[i], \"*\",\n              \"(\", a[i+1:], \"=\", (cusum_a[-1] - cusum_a[i]), \")\",\n              \"=\", a[i] * (cusum_a[-1] - cusum_a[i]))\n        \"\"\"\n        ans %= mod\n\n    return ans\n\n\nn = int(input())\na = list(map(int, input().split(\" \")))\nprint((solve1(n, a)))\n", "passed": true, "time": 0.21, "memory": 14316.0, "status": "done"}, {"code": "import sys\n# from numpy import cumsum\ninput = sys.stdin.readline\nn = int(input())\na = [int(_) for _ in input().split()]\nmod = 10**9 + 7\nans = 0\ns = [0]\na_ = a[::-1]\nfor i in range(len(a_)-1):\n  s.append(s[i]+a_[i])\ns = s[::-1]\ns.pop(len(s)-1)\n# print(s)\nfor i in range(len(a)-1):\n  ans += a[i] * s[i]\n  ans = ans % mod\nprint(ans)", "passed": true, "time": 0.14, "memory": 14284.0, "status": "done"}, {"code": "CONST = 10 ** 9 + 7\nN = int(input())\nnumbers = list(map(int, input().split()))\nr = 0\n\n\ndef cumsum(xs):\n    result = []\n    for i in range(len(xs)):\n        if i == 0:\n            result.append(xs[0])\n        else:\n            result.append(result[-1] + xs[i])\n    return result\n\n\nnumbers.reverse()\nnum_sum = cumsum(numbers)\nnum_sum.reverse()\nnumbers.reverse()\ndel num_sum[0]\nfor i in range(N - 1):\n    r += (numbers[i] * num_sum[i]) % CONST\nprint((r % CONST))\n", "passed": true, "time": 0.14, "memory": 14212.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\ns = sum(a)\nx = [i**2 for i in a]\nx = sum(x)\nans = (s**2-x)//2\nprint(ans%(10**9+7))", "passed": true, "time": 0.14, "memory": 14128.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\ns = [0]*(n+1)\nmod = 10**9 + 7\nfor i in range(1,n+1):\n    s[i] = s[i-1] + a[i-1]\nans = 0\nfor j in range(1,n):\n    ans += a[j-1]*(s[n]-s[j])\nprint(ans%mod)", "passed": true, "time": 0.14, "memory": 14104.0, "status": "done"}, {"code": "# -*- coding utf-8 -*-\n\nMOD = 10 ** 9 + 7\n\nN = int(input())\nAN = list(map(int, input().split()))\n\ncumsum = [0] * (len(AN) + 1)\nfor i in range(1, N + 1):\n    cumsum[i] = cumsum[i - 1] + AN[i - 1]\n\nans = 0\nfor i in range(1, N):\n    ans += AN[i] * cumsum[i]\n    ans %= MOD\n\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "n = input()\na = list(map(int,input().split()))\nsum = 0\nmsum = 0\nfor i in a:\n  sum += i\n  msum += i*i\nans = int((sum*sum - msum)//2)\nprint(int(ans%1000000007))", "passed": true, "time": 0.14, "memory": 14288.0, "status": "done"}, {"code": "n = int(input())\nl = list(map(int,input().split()))\nA = sum(l)-l[0]\nans = 0\nfor i in range(len(l)) :\n    ans += l[i]*A\n    \n    if A == l[-1] :\n        break\n    else :\n        A -= l[i+1]\n\nprint(ans%(10**9+7))", "passed": true, "time": 0.14, "memory": 14124.0, "status": "done"}, {"code": "#abc177c\nn=int(input())\na=list(map(int,input().split()))\ns=sum(a)\nt=sum([x*x for x in a])\nprint(((s*s-t)//2%(10**9+7)))\n", "passed": true, "time": 0.14, "memory": 14064.0, "status": "done"}, {"code": "def cin():\n    return list(map(int, input().split()))\n\n\nN = int(input())\nA = cin()\n\ntotal = 0\nstore = 0\nfor i in range(N - 1):\n    store += A[N - i - 1]\n    total += A[N - i - 2] * store\nprint((total % (pow(10, 9) + 7)))\n", "passed": true, "time": 0.64, "memory": 14096.0, "status": "done"}, {"code": "N=int(input())\nb = 0\na = list(map(int, input().split()))\nc = 0\nfor i in range(0,N):\n  c = c + a[i]\nfor i in range(0,N):\n  c = c - a[i]\n  b = (b + a[i] * c) %(10**9+7)\nprint(b)", "passed": true, "time": 0.68, "memory": 14304.0, "status": "done"}, {"code": "N = int(input())\nmod = 10**9 + 7\nA = list(map(int, input().split()))\nAsum = sum(A)\nans = 0\nfor a in A:\n  Asum -= a\n  ans += a*Asum % mod\nprint(ans % mod)", "passed": true, "time": 0.14, "memory": 14220.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\ncount = 0\nans = 0\nfor i in range(1,n):\n  count += a[-i]\n  ans += a[-i-1]*count\n  ans = ans%(10**9+7)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14312.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\ns = sum(a)\nans = 0\nfor i in a:\n    s -= i\n    ans += i*s\nmod = ans % (10**9 + 7)\nprint(mod)", "passed": true, "time": 0.14, "memory": 14264.0, "status": "done"}, {"code": "MOD=10**9+7\nN=int(input())\nA=list(map(int,input().split()))\nsum_of_all=sum(A)**2\nsum_of_diagonal=0\nfor i in range(N):\n  sum_of_diagonal+=A[i]**2\nprint((sum_of_all-sum_of_diagonal)//2%MOD)", "passed": true, "time": 0.23, "memory": 14340.0, "status": "done"}, {"code": "CONST = 10 ** 9 + 7\nN = int(input())\nnumbers = list(map(int, input().split()))\nr=0\n\ndef cumsum(xs):\n    result = []\n    for i in range(len(xs)):\n        if i == 0:\n            result.append(xs[0])\n        else:\n            result.append(result[-1] + xs[i])\n    return result\nnumbers.reverse()\nnum_sum = cumsum(numbers)\nnum_sum.reverse()\nnumbers.reverse()\ndel num_sum[0]\nfor i in range(N-1):\n    r+=(numbers[i]*num_sum[i])%CONST\nprint(r%CONST)", "passed": true, "time": 0.36, "memory": 14272.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int, input().split()))\n\nmod = 10 ** 9 + 7\ns = sum(A) % mod\nans = 0\nfor i in range(n):\n    s -= A[i]\n    ans = (ans + (A[i] * s) % mod) % mod\nprint(ans)", "passed": true, "time": 0.15, "memory": 14068.0, "status": "done"}, {"code": "n = int(input())\nc = list(map(int, input().split()))\nc_ans = []\nans = 0\n\n#print(c)\nfor i in range(n):\n  ans += c[i]\n  #print(ans)\n  c_ans.append(ans)\n    \nre_ans = 0\n#print(c_ans)\n\nfor i in range(n):\n  re_ans += c[i] * (c_ans[n-1] - c_ans[i])\n\nre_ans = re_ans % (10**9 + 7)\nprint(re_ans)", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int, input().split()))\n\ntotal = (sum(A))**2\nfor i in range(n):\n     total -= (A[i])**2\nans = (total//2)%(10**9+7)\nprint(ans)\n", "passed": true, "time": 0.23, "memory": 14372.0, "status": "done"}, {"code": "from functools import reduce\nfrom operator import add\n\nN = int(input())\nA = list(map(int, input().split()))\n\ndef cum(total, a):\n    total.append(a + total[-1])\n    return total\n\ncumsum = reduce(cum, A, [0])\ncum_last = cumsum[-1]\n\np = 1000000007\n\ndef i_fixed(i):\n    return (A[i] * (cum_last - cumsum[i+1])) % p\n\ndef solve():\n    return map(i_fixed, range(N-1))\n\nprint(sum(solve()) % p)", "passed": true, "time": 0.14, "memory": 14056.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nans = 0\nmod = 10**9 + 7\nb = sum(a)\n\nfor i in range(n-1):\n    b = b-a[i]\n    ans += a[i]*b\n\nprint(ans%mod)", "passed": true, "time": 0.14, "memory": 14268.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\n\nsuma = sum(a)\nans = 0\nfor i in range(len(a)):\n  suma = suma - a[i]\n  ans += suma * a[i]\nans = ans % (10**9+7)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14104.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int, input().split()))\ns=[]\nc=0\nans = 0\nfor i in a:\n\tc += i\n\ts.append(c)\nfor i in range(n-1):\n\tans += (a[i] * (s[n-1]-s[i])) % 1000000007\nprint(ans % 1000000007)", "passed": true, "time": 0.14, "memory": 14152.0, "status": "done"}, {"code": "def __starting_point():\n\n    N = int(input())\n    A = list(map(int, input().lstrip().split(' ')))\n\n    cumA = [A[0]]\n    for i in range(1,N):\n        cumA.append(cumA[-1] + A[i])\n    \n    count = 0\n    for i in range(N - 1):\n        count += A[i] * ( cumA[N-1] - cumA[i] )\n    \n    print(count % (10**9 + 7))\n__starting_point()", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "def main():\n    N = int(input())\n    mod = 10**9 + 7\n    \n    a = list(map(int, input().split()))\n\n    ans = 0\n    s = 0\n    \n    for i in range(1, N):\n        s += a[i]\n    \n        \n    for i in range(1, N):\n        ans += (a[i-1] * s) % mod\n        s -= a[i]\n            \n    print(ans % mod)\n            \n    \n    \ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14244.0, "status": "done"}, {"code": "N = int(input())\nA = [int(a) for a in input().split()]\nmod = 10**9+7\n\nL = [0]*(N+1)\nfor i in range(N):\n    L[i+1] = (L[i]+A[i])%mod\n\nans = 0\nfor i in range(N):\n    ans += A[i]*(L[-1]-L[i+1])\n    ans %= mod\nprint(ans)", "passed": true, "time": 0.14, "memory": 14204.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\n\nmod = 10**9+7\n\nsum_list = []\nsum_ = 0\nfor i in range(len(A)-1):\n    sum_ += A[i+1]\n    sum_list.append(sum_)\n    \nlen_ = 0\nfor i in range(len(A)-1):\n    len_ += (A[i+1] * (sum_list[-1] - sum_list[i]) )% mod\n\nprint(((len_+A[0]*sum_list[-1])%mod))\n", "passed": true, "time": 0.15, "memory": 14292.0, "status": "done"}, {"code": "N, = map(int,input().split())\nA = list(map(int,input().split()))\nsu = A[N-1]\nsuu = su*A[N-2]\nfor i in reversed(range(1,N-1)):\n  su+=A[i]\n  suu+=(su*A[i-1])\nprint(suu%(10 ** 9+7))", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "import sys\nn=int(input())\na=[int(x) for x in input().split()]\n\ns=0\nfor i in range(n):\n    s+=a[i]\nc=0\nsum=0\nfor k in range(n-1):\n    c+=a[k]\n    co=s-c\n    sum+=a[k]*co\n\nprint((sum%(10**9+7)))\n", "passed": true, "time": 0.16, "memory": 14300.0, "status": "done"}, {"code": "from sys import stdin\nN = int(stdin.readline().rstrip())\nA = [int(_) for _ in stdin.readline().rstrip().split()]\n\nsa = sum(A)\nans = 0\n\nfor i in range(N):\n    sa -= A[i]\n    ans += A[i]*sa    \n    ans %= (10**9+7)\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14332.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nrsum = [0 for _ in range(N)]\nans = 0\nfor i in range(N):\n    if i == 0:\n        continue\n    rsum[-(i+1)] = rsum[-i] + A[-i]\nfor i in range(N):\n    ans += A[i] * rsum[i]\nans %= (10 ** 9 + 7)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int, input().split()))\n\ns = 0\nsum = 0\nans = 0\n\nfor i in range(n):\n  s += A[i]\n\nfor j in range(n-1):\n  s -= A[j]\n  sum += A[j] * s\n\nans = sum % (10**9+7)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14308.0, "status": "done"}, {"code": "MOD = 10 ** 9 + 7  # MOD\u306f\u5909\u6570\u306b\u5165\u308c\u3066\u3057\u307e\u3063\u305f\u307b\u3046\u304c\u6253\u3061\u9593\u9055\u3048\u306a\u304f\u3066\u3044\u3044\u3067\u3059\n\nN = int(input())\nA = list(map(int, input().split()))\n\nS = sum(A) % MOD\nans = 0\n\n# A_N\u3082\u542b\u307e\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u304c\u3001\u305d\u306e\u3068\u304d\u306fs=0\u306a\u306e\u3067\u554f\u984c\u3042\u308a\u307e\u305b\u3093\nfor x in A:\n    S -= x  # \u81ea\u5206\u3068\u81ea\u5206\u81ea\u8eab\u3092\u639b\u3051\u306a\u3044\u3088\u3046\u306b\u3001\u5148\u306b\u5f15\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\n    S %= MOD  # MOD\u306f\u3044\u3061\u3044\u3061\u53d6\u3063\u3066\u304a\u304f\u3068\u3044\u3044\u3067\u3059\n    ans += S * x\n    ans %= MOD\n\nans %= MOD  # \u3053\u306e\u884c\u306f\u5b8c\u5168\u306b\u4e0d\u8981\u3067\u3059\u304c\u3001\u6700\u5f8c\u3060\u3051MOD\u3092\u53d6\u308a\u5fd8\u308c\u3066WA\u306b\u306a\u308b\u30df\u30b9\u306f\u975e\u5e38\u306b\u3088\u304f\u3042\u308b\u306e\u3067\u3001\u5fc5\u8981\u4ee5\u4e0a\u306b\u53d6\u3063\u3066\u304a\u304f\u3068\u5b89\u5fc3\u3067\u304d\u307e\u3059\nprint(ans)", "passed": true, "time": 0.14, "memory": 14228.0, "status": "done"}, {"code": "p = 10**9 + 7\nn = int(input())\naa = list(map(int, input().split()))\ns = 0\nfor a in aa:\n  s += a**2\n\nsa = sum(aa)\nb = sa*sa\nans = (b-s)//2\n\nprint(ans % p)", "passed": true, "time": 0.14, "memory": 14328.0, "status": "done"}, {"code": "mod = 1000000000+7\n\nn = int(input())\nAs = list(map(int, input().split()))\n\n\nsum_ = sum(As)\nret = 0\nfor i in range(n-1):\n    sum_ -= As[n-1-i]\n    ret += sum_ * As[n-1-i]\n    ret %= mod\n\nprint(ret)", "passed": true, "time": 0.14, "memory": 14264.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nmod = 10**9 + 7\nb = sum(a)\nc = sum([i*i for i in a])\nans = ((b**2 - c)//2)%mod\nprint(ans)", "passed": true, "time": 0.14, "memory": 14088.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nmysum = sum(A)\ntotal = 0\nfor i in range(N-1):\n    mysum -= A[i]\n    total += A[i] * mysum\nprint(total % 1000000007)", "passed": true, "time": 0.14, "memory": 14124.0, "status": "done"}, {"code": "n = int(input())\nli = list(map(int, input().split()))\nmod = 10**9 + 7\nsm = sum(li)\nmul = sum([i**2 for i in li])\nans = ((sm ** 2 - mul) // 2) % mod\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14088.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\n\n# \u89e3\u8aac\u3092\u8aad\u3093\u3067\u89e3\u3044\u305f\n\n# \u7d2f\u7a4d\u548c\u306e\u8a08\u7b97\n\nsm = [0]\nfor i in range(N):\n  sm.append(sm[i]+A[i])\n\n# \u7d2f\u7a4d\u548c\u3092\u4f7f\u3063\u305f\u89e3\u7b54\nans = 0\nfor j in range(N):\n  ans += A[j]*(sm[N]-sm[j+1])\n  \nprint(ans % (10**9+7))", "passed": true, "time": 0.15, "memory": 14244.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nMOD = 10 ** 9 + 7\n\nS = sum(A) % MOD\n\nans = 0\nfor i in range(N - 1):\n    S -= A[i]\n    S %= MOD\n    ans += (A[i] % MOD) * S\n    ans %= MOD\n    \nprint(ans)", "passed": true, "time": 0.14, "memory": 14276.0, "status": "done"}, {"code": "N=int(input())\nA=[0]*N\nS=[0]*(N+1)\nA=list(map(int,input().split()))\nmod=10**9+7\n\nfor i in range(N):\n    S[i+1]=(S[i]+A[i])%mod\n\ncnt=0\nfor j in range(N-1):\n    cnt+=A[j]*(S[N]-S[j+1])%mod\n\nprint(cnt%mod)", "passed": true, "time": 0.14, "memory": 14064.0, "status": "done"}, {"code": "import sys\n\n\ndef input():\n    return sys.stdin.readline().strip()\n\n\nsys.setrecursionlimit(20000000)\n\nMOD = 10 ** 9 + 7\nINF = float(\"inf\")\n\n\ndef main():\n    N = int(input())\n    A = list(map(int, input().split()))\n    for i in range(N):\n        A[i] %= MOD\n    S = sum(A)\n    answer = 0\n    for i in range(N):\n        S = S - A[i]\n        answer += A[i] * S\n        answer %= MOD\n    print(answer)\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.15, "memory": 14252.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\n\nmod = 1000000007\nsum = 0\nans = 0\nfor i in range(n):\n\tans = (ans + a[i]*sum) % mod\n\tsum += a[i]\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14272.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\n\nans = 0\n\nMOD = 10 ** 9 + 7\n\nsum_A = sum(A)\n\nfor i in range(N):\n    sum_A -= A[i]\n    ans += (sum_A * A[i])\n\nprint((ans % MOD))\n", "passed": true, "time": 0.18, "memory": 14260.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\n\nMOD = 10**9 + 7\ns = 0\n\nfor i in range(N):\n  s += A[i]\nans = 0\nfor i in range(N-1):\n  s -= A[i]\n  ans += A[i] * s\n  ans %= MOD\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14364.0, "status": "done"}, {"code": "mod = 10 ** 9 + 7\nN = int(input())\nA = list(map(int,input().split()))\nsum_of_all = sum(A)**2\nsum_of_diagonal = 0\nfor i in range(N):\n  sum_of_diagonal += A[i]**2\nprint((sum_of_all - sum_of_diagonal) // 2 % mod)", "passed": true, "time": 0.15, "memory": 14236.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\n\nM = 10**9 + 7\n\nAns = 0\n\nT = sum(A)\n\nfor i in range(N-1):\n    T -= A[i]\n    Ans += A[i] * T\n    Ans %= M\n\nprint(Ans)\n", "passed": true, "time": 0.14, "memory": 14284.0, "status": "done"}, {"code": "n=int(input())\nli=list(map(int,input().split()))\ns=sum(li)\nc=0\nfor i in range(n-1):\n    s-=li[i]\n    c+=li[i]*s\nprint(c%(10**9+7))", "passed": true, "time": 0.14, "memory": 14124.0, "status": "done"}, {"code": "import itertools\n\nn = int(input())\na = list(map(int,input().split()))\nans = 0\n\nlis = list(itertools.accumulate(reversed(a)))\n\nfor i in range(n-1):\n  ans += a[i]*lis[n-2-i]\n    \nprint(ans%(10**9 + 7))", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nlim = (10 ** 9) + 7\nans = 0\ntemp = a[-1]\nfor i in range(2,n+1):\n  ans += a[-i] * temp\n  temp += a[-i]\n#  print(\"ans = {} temp = {}\".format(ans,temp))\n\nprint(ans%lim)", "passed": true, "time": 0.14, "memory": 14180.0, "status": "done"}, {"code": "n = int(input())\nli = list(map(int,input().split()))\ns = [li[0]]\nans = 0\nm = 10**9 +7\nfor i in range(n-1):\n    s.append(li[i+1] + s[i])\n\nfor j in range(n-1):\n    ans += (li[j] * (s[n-1]-s[j])) % m\n\nprint(ans%m)", "passed": true, "time": 0.14, "memory": 14244.0, "status": "done"}, {"code": "mod = 10**9 + 7\n\nn = int(input())\na = list(map(int, input().split()))\ns = sum(a) % mod\nans = 0\n\nfor x in a:\n  s -= x\n  s %= mod\n  ans += s * x\n  ans %= mod\n  \nans %= mod\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "mod = 10**9 + 7\nn = int(input())\na = [int(i) for i in input().split()]\ns = sum(a)\nout = 0\nfor i in a:\n  s -= i\n  out += s * i\n  out %= mod\nprint(out)", "passed": true, "time": 0.14, "memory": 14040.0, "status": "done"}, {"code": "N = int(input())\nnum = list(map(int, input().split(' ')))\nans = 0\ntotal = sum(num)\nMOD = 10 ** 9 + 7\nfor a in num:\n    total -= a\n    ans += a * total \n    ans %= MOD\nans %= MOD\nprint(ans)", "passed": true, "time": 0.14, "memory": 14268.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\n\nmod = (10**9)+7\nans = 0\nsums = [0]*N\nsums[0] = A[0]\nfor i in range(1, N):\n    sums[i] = sums[i-1] + A[i]\n\nfor j in range(N):\n    ans += A[j]*(sums[-1]-sums[j])\n\nprint(ans%mod)", "passed": true, "time": 0.14, "memory": 14260.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\na_sum = sum(a)\nans = 0\nmod = 10**9 + 7\n\nfor i in range(n-1):\n    a_sum = a_sum - a[i]\n    ans += a[i] * a_sum\n\nprint(ans%mod)", "passed": true, "time": 0.14, "memory": 14300.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int, input().split()))\nmod = 10 ** 9 + 7\nrr = [0 for i in range(n + 1)]\n\nfor i in range(n):\n    rr[i + 1] = (A[i] + rr[i]) % mod\n\nans = 0\nfor i in range(n):\n    ans += A[i] * (rr[n] - rr[i + 1]) % mod\n\nprint((ans % mod))\n", "passed": true, "time": 0.14, "memory": 14300.0, "status": "done"}, {"code": "import itertools\nn = int(input())\nA = list(map(int, input().split()))\nA2=[]\nfor i in range(n):\n    A2.append(A[n-1-i])\n\nacc_A2 = list(itertools.accumulate(A2))\nmod = (10**9)+7\n\ngoukei = 0\n\nfor i in range(n-1):\n    goukei += A[i]*acc_A2[n-2-i]\n\nprint(goukei%mod)", "passed": true, "time": 0.14, "memory": 14160.0, "status": "done"}, {"code": "CONST = 10 ** 9 + 7\nN = int(input())\nnumbers = list(map(int, input().split()))\nr=0\n\ndef cumsum(xs):\n    result = []\n    for i in range(len(xs)):\n        if i == 0:\n            result.append(xs[0])\n        else:\n            result.append(result[-1] + xs[i])\n    return result\nnumbers.reverse()\nnum_sum = cumsum(numbers)\nnum_sum.reverse()\nnumbers.reverse()\ndel num_sum[0]\nfor i in range(N-1):\n    r+=(numbers[i]*num_sum[i])%CONST\nprint((r%CONST))\n", "passed": true, "time": 0.14, "memory": 14100.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int,input().split()))\npaA = [0 for _ in range(n-1)]\npaA[0] = A[n-1]\nmod = 10**9 + 7\nfor i in range(1,n-1):\n    paA[i] = paA[i-1] + A[n-1-i]\nsuma = 0\nfor i in range(n-1):\n    suma += A[i] * paA[n-i-2]\n    suma = suma % mod\nprint(suma)", "passed": true, "time": 0.14, "memory": 14236.0, "status": "done"}, {"code": "n = int(input())\na_list = list(map(int, input().split()))\n\nsum = 0\ns_list=[]\nans = 0\n\nfor i in range(n):\n    sum += a_list[i]\n    s_list.append(sum)\n\nfor i in range(n-1):\n    ans += a_list[i] * (s_list[n-1]-s_list[i])\n\nprint((ans % (7+10**9)))\n", "passed": true, "time": 0.14, "memory": 14332.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\na.sort()\ns = sum(a)\nx = [i**2 for i in a]\nx = sum(x)\nans = (s**2-x)//2\nmod = 10**9+7\nprint(ans%mod)", "passed": true, "time": 0.14, "memory": 14352.0, "status": "done"}, {"code": "import sys\n\nN = int(input())\nA = list(map(int, input().split()))\n\nsum = [A[N-1]]\nans = 0\nfor i in range(1, N):\n    ans += A[N-i-1]*sum[-1]%(10**9+7)\n    ans %= (10**9+7)\n    sum.append((sum[-1]+A[N-i-1])%(10**9+7))\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14324.0, "status": "done"}, {"code": "mod = 10**9+7\nn = int(input())\nl = list(map(int, input().split()))\nans = []\na = sum(l)\nfor i in range(len(l)):\n  a = a - l[i]\n  ans.append(l[i] * a)\n\nprint((sum(ans)%mod))\n\n\n", "passed": true, "time": 0.17, "memory": 14036.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\nmod=10**9+7\nsm=sum(a)\nmul=sum(i**2 for i in a)\nans=((sm ** 2 - mul) // 2) % mod\nprint(ans)\n\n", "passed": true, "time": 0.14, "memory": 14076.0, "status": "done"}]