Problem:


Score : 300 points

Problem Statement

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 1

3
1 2 3

Sample Output 1

11

We have 1 \times 2 + 1 \times 3 + 2 \times 3 = 11.

Sample Input 2

4
141421356 17320508 22360679 244949

Sample Output 2

437235829



Sample input:
3
1 2 3


Sample output:
11

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(1, N):
    ans += A[i - 1] * sum(A[i:])
print(ans % (10**9 + 7))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(1, N):
    for j in range(i, N):
        ans += A[i - 1] * A[j]
print(ans % (10**9 + 7))

Submission status: Time Limit Exceeded

Solution code:
# -*- using:utf-8 -*-
from itertools import combinations

class main:
  def v(array):
    sum = 0
    for i in range(len(array)):
      sum += array[i][0] * array[i][1]
    sum = sum % 1000000007
    print(sum)

if __name__ == "__main__":
  n = int(input())
  li = list(map(int, input().split()))
  array = list(combinations(li, 2))
  main.v(array)

Submission status: Time Limit Exceeded

Solution code:
# -*- using:utf-8 -*-
from itertools import combinations

class main:
  def v(array):
    sum = 0
    mod = 1000000007
    for i in range(len(array)):
      sum += array[i][0] * array[i][1]
    ans = sum % mod
    print(ans)

if __name__ == "__main__":
  n = int(input())
  li = list(map(int, input().split()))
  array = list(combinations(li, 2))
  main.v(array)

Submission status: Time Limit Exceeded

Solution code:
# -*- using:utf-8 -*-
from itertools import combinations

if __name__ == "__main__":
  n = int(input())
  li = list(map(int, input().split()))
  array = list(combinations(li, 2))
  sum = 0
  mod = 1000000007
  for i in range(len(array)):
    sum += array[i][0] * array[i][1]
  ans = sum % mod
  print(ans)

Submission status: Time Limit Exceeded

Solution code:

md=10**9+7
t=1
# t=int(input())

for some_num in range(0,t):
    n=int(input())
    vals=[int(i) for i in input().split(" ")]

    sum=0

    for i in range(0,n-2):
        ts=0
        for j in range(i+1,n):
            ts+=(vals[j])

        sum=(sum+ ts*vals[i])% md

    sum=(vals[n-1]*vals[n-2] + sum )%md


print(sum)

Submission status: Time Limit Exceeded

Solution code:

md=10**9+7
t=1
# t=int(input())

for some_num in range(0,t):
    n=int(input())
    vals=[int(i) for i in input().split(" ")]

    sum=0

    for i in range(0,n):
        for j in range(0,i):
            sum=(sum + vals[i]*vals[j])%md

print(sum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))

MOD = 10 ** 9 + 7

C = []

for i in range(len(A)-1):
   for j in range(i+1, len(A)):
      C.append((A[i] * A[j]))

print(sum(C) % MOD)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
def main():
    a = int(input())
    p = list(map(int,input().split()))
    mod = 10**9 + 7
    sum_list =[p[i]*p[t] for i in range(a) for t in range(a) if i<t ]
    num = np.sum(sum_list)
    num = num%mod
    return num
num = main()
print(num)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))

sum = 0

for i in range(N - 1):
  for j in range(i + 1, N):
    sum += A[i] * A[j]
    
ans = sum % (10**9 + 7)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
"""
https://atcoder.jp/contests/abc177/tasks/abc177_c
"""


def solve(n, a):
    s = 0
    for i in range(n):
        for j in range(i + 1, n):
            s += a[i] * a[j]

    s = s % (10**9 + 7)
    return s


n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Submission status: Time Limit Exceeded

Solution code:
#C - Sum of product of pairs
N = int(input())
A = list(map(int,input().split()))
SUM = 0
MOD = 1000000007
for i in range(N-1):
    for j in range(i+1,N):
            SUM = (SUM + (A[i] * A[j] % MOD) ) % MOD

# 出力
print(SUM)

Submission status: Time Limit Exceeded

Solution code:
#C - Sum of product of pairs
N = int(input())
A = list(map(int,input().split()))
SUM = 0
MOD = 1000000007
for i in range(N-1):
    for j in range(i+1,N):
            SUM = (SUM + (A[i] * A[j] % MOD) ) % MOD

# 出力
print(SUM)

Submission status: Time Limit Exceeded

Solution code:
#C - Sum of product of pairs
N = int(input())
A = list(map(int,input().split()))
SUM = 0
MOD = 1000000007
for i in range(N-1):
    for j in range(1,N):
        if i < j:
            SUM = (SUM + (A[i] * A[j] % MOD) ) % MOD

# 出力
print(SUM)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a = list(map(int,input().split()))
def p(val):
    print(val)

sho = 10**9 +7
count = 0
for i in range(n-1):
    for j in range(i+1,n):
        count += ((a[i]%sho)*(a[j]%sho)) % sho
        #if count > sho:
        #   count = count%sho
p(count%sho)

Submission status: Time Limit Exceeded

Solution code:
import itertools
n = int(input())
a = list(map(int, input().split()))
suf = list(itertools.combinations(range(n), 2))
total = 0
mod = 10**9 + 7
for i, j in suf:
    # print(i, j)
    total = (total + (a[i] * a[j]) % mod) % mod
print(total)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a = list(map(int,input().split()))
def p(val):
    print(val)

sho = 10**9 +7
count = 0
for i in range(n-1):
    for j in range(i+1,n):
        count += ((a[i]%sho)*(a[j]%sho)) % sho
        if count > sho:
            count = count%sho
p(count)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a = list(map(int,input().split()))
def p(val):
    print(val)

sho = 10**9 +7
count = 0
for i in range(n-1):
    for j in range(i+1,n):
        count += (a[i]*a[j]) % sho
        if count > sho:
            count = count%sho
p(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        ans += a[i] * a[j]
print(ans % (10**9 + 7))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(a) for a in input().split()]
p = 10 ** 9 + 7

AA = [a % p for a in A]
sum = 0
for i in range(0, N - 1):
  for j in range(i + 1, N):
    sum += (AA[i] * AA[j]) % p
print(sum % p)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations 

N = int(input())
A = list(map(int, input().split()))

comb = combinations(A, 2) 
ans = 0
mod = 10**9 + 7

for i in list(comb):
  y = (i[0] * i[1])
  ans += y

print(ans % mod)

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())
A = [int(n) for n in input().split()]
ans = 0
m = 1000000007

for x, y in itertools.combinations(A, 2):
    ans += x * y

print(ans % m)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
    ans += A[i] * sum(A[i+1:])

print(ans % ((10 ** 9) + 7))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
L=[int(x) for x in input().split()]
sum=0
mod=1000000007
for i in range(n-1):
    for j in range(i+1,n):
        sum+=(L[i]*L[j])%mod
print(sum%mod)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    A = list(map(int,input().split()))
    MOD = 10**9 +7

    S = 0
    for i in range(len(A)-1):
        tmp = 0
        for j in range(i+1,len(A)):
            tmp+=A[j]
        S+= (tmp%MOD * A[i])%MOD


    print(S%MOD)

main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    A = list(map(int,input().split()))
    MOD = 10**9 +7

    S = 0
    for i in range(len(A)-1):
        for j in range(i+1,len(A)):
            S = (S + A[i]*A[j]%MOD)%MOD

    print(S)

main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
arr = list(map(int,input().split()))
sum = 0
for i in range(n-1):
    for j in range(i+1,n):
        sum += arr[i]*arr[j]
print(sum%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
su = 0

for i in range(0,N-1):
    for j in range(i+1,N):
        su += A[i]*A[j]

print(su % (10**9 + 7))

Submission status: Time Limit Exceeded

Solution code:
MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
ans = 0
B = [0]*(N-1)
for i in range(1, N):
    B[i-1] = sum(A[i:N])
for i in range(0, N-1):
    ans += A[i] * B[i]
    ans %= MOD
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))

mo=10**9+7
an=0
wk=0
for i in range(n-1):
    for j in range(i+1,n):
        wk+=(a[j]%mo)
    an+=(a[i]*(wk%mo))%mo
    an%=mo
    wk=0
print(an)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
sum_=0
for i in range(n-1):
    for j in range(n-i-1):
        sum_ += A[i]*A[i+j+1]
        sum_ %= mod
print(sum_)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
for i in range(n):
    if A[i] >= mod:
        A[i] %= mod
sum_=0
for i in range(n-1):
    for j in range(n-i-1):
        sum_ += A[i]*A[i+j+1]
        sum_ %= mod
print(sum_)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))

mo=10**9+7
an=0
for i in range(n-1):
    for j in range(i+1,n):
        an+=(a[i]%mo)*(a[j]%mo)
        an%=mo
print(an)

Submission status: Time Limit Exceeded

Solution code:
MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
temp = 0
B = [0]*(N-1)
for i in range(1, N):
    B[i-1] = sum(A[i:N])
for i in range(0, N-1):
    temp = temp + (A[i] * B[i])
print(temp % MOD)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        ans += A[i] * A[j]
        ans = ans % (10 ** 9 + 7)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = list(map(int, input().split()))
ans = 0

for i in range(n-1):
    ans += A[i]*sum(A[i+1:])
    ans %= 1000000007

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = list(map(int, input().split()))
ans = 0

for i in range(n-1):
    for j in range(i+1, n):
        ans += A[i]*A[j]
        ans %= 1000000007

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = int(input())
array = np.array(list(map(int, input().split())))

total = 0
for i in range(N-1):
    total += sum(array[i] * array[i+1:])
print(total%((10**9)+7))

Submission status: Time Limit Exceeded

Solution code:
import itertools

n = int(input())
A = list(map(int, input().split()))
ans = 0

for pair in itertools.combinations(A, 2):
    ans += (pair[0]*pair[1])
    ans %= 1000000007

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(x) for x in input().split(" ")]

from itertools import combinations

mod = 1000000007  # 丁度いい大きさの素数だけで意味は特にない。
s = 0
for c in combinations(A, 2):
    s += c[0] * c[1]

print(s % mod)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        ans += nums[i] * nums[j]
print(ans%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
array = list(map(int, input().split()))
print(sum([array[i]*array[j] for i in range(N) for j in range(i+1, N)])%((10**9)+7))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
num = 0
for i in range(n):
    num += a[i]*sum(a[i+1:])
print(num%((10**9)+7))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = int(input())
array = list(map(int, input().split()))

array2 = [array[i]*array[j] for i in range(N) for j in range(i+1, N)]
print(sum(array2)%((10**9)+7))

Submission status: Time Limit Exceeded

Solution code:
import itertools
n = int(input())
a = list(map(int, input().split()))
num = 0
for i,j in itertools.combinations(a,2):
    num += i*j
print(num%((10**9)+7))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
s = 0
t = 0

for i in range(n-1):
    for j in a[i+1:]:
        t += a[i]*j
u = t % (10**9+7)
print(u)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
s = 0
t = 0

for i in range(n-1):
    for j in a[i+1:]:
        t += a[i]*j
u = t % (10**9+7)
print(u)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations, accumulate
def calc(tup):
  return (tup[0]*tup[1])
n = int(input())
a = list(map(int, input().split()))
a_comb = list(map(calc, list(combinations(a, 2))))
c_sum = list(accumulate(a_comb))
print(c_sum[-1]%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
def calc(tup):
  return (tup[0]*tup[1])
n = int(input())
a = list(map(int, input().split()))
a_comb = list(combinations(a, 2))
ans = 0 
for i in a_comb:
  ans += calc(i)
  if ans >= (10**9+7):
    ans = ans%(10**9+7)
print(ans%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    MOD = 10 ** 9 + 7
    sum = 0

    for i in range(len(A)):
        for j in range(i+1, len(A)):
            sum += A[i] * A[j]
    
    ans = sum % MOD
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    MOD = 10 ** 9 + 7
    sum = 0

    for i in range(len(A)):
        for j in range(i+1, len(A)):
            sum += A[i] * A[j]

    print(sum % MOD)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))

comb = len(a) * (len(a) - 1) / 2
comb = int(comb)

sum = 0

for i in range(comb):
    #print(a)
    for i in range(1, len(a)):
        #print(a[i])
        sum = sum + a[0] * a[i]
    a = a[1:]
    #print(a)

print(sum % (10**9 + 7))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))

A = list(map(lambda x: x%(1*10**9 + 7), A))


value = 0
plus = 0
ans = 0

for i in range(N-1):
    for j in range(N-i-1):
        value = (A[i]*A[i+j+1]+value) % (1*10**9 + 7)
        

print(value)

Submission status: Time Limit Exceeded

Solution code:

N = int(input())
A = list(map(int,input().split()))
value = 0
plus = 0
ans = 0

for i in range(N-1):
    for j in range(N-i-1):
        plus = A[i]*A[i+j+1] % (1*10**9 + 7)
        value = (value + plus) % (1*10**9 + 7)
        

print(value)

Submission status: Time Limit Exceeded

Solution code:
# C
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 10**9+7
for i in range(n-1):
    for j in range(i+1, n):
        ans += (a[i]*a[j])
print(int(ans % mod))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
value = 0

for i in range(N-1):
    for j in range(N-i-1):
        value += A[i]*A[i+j+1]  
        value = value % (1*10**9 + 7)


print(value)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
value = 0

for i in range(N-1):
    for j in range(N-i-1):
        value += A[i]*A[i+j+1]  


ans = value % (1*10**9 + 7)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 0

    for i in range(N):
        for j in range(i + 1, N):
            ans += A[i] * A[j]

    print(ans % (10**9 + 7))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
s=0
for i in range(n-1):
    j=i+1
    while j<=n-1:
        s+=a[i]*a[j]
        j+=1

ans=s%(10**9+7)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# https://atcoder.jp/contests/abc177/submissions/16358885

N = int(input())
A = list(map(int, input().split()))
B = []  # 累積和テーブル B[i] = sum(A[:i])
mod = 10**9 + 7
ans = 0

for i in range(N+1):
    B.append(sum(A[:i]))  # 累積和

for i in range(N):
    sum = (B[N] - B[i+1]) % mod
    ans += A[i] * sum
    ans %= mod

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
As = list(map(int, input().split()))

_sum = 0
for i in range(len(As) - 1):
    _sum += As[i+1] * sum(As[0:i+1])

print(_sum % (10**9 + 7))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ai_char = map(str, input().split(" "))
Ai = []
for i in ai_char:
    Ai.append(int(i))

mod_val = 1000000007
N1 = N-1
sum = 0
for i in range(N1):
    sum_tmp = 0
    for j in range(i+1, N):
        sum_tmp += Ai[j]
    sum += Ai[i] * sum_tmp

    if sum > mod_val:
        sum = sum % mod_val


print(int(sum))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ai_char = map(str, input().split(" "))
Ai = []
for i in ai_char:
    Ai.append(int(i))

mod_val = 1000000007
sum = 0
for i in range(N-1):
    for j in range(i+1, N):
        sum += Ai[i]*Ai[j]
        if sum > mod_val:
            sum = sum % mod_val
        #print("{} {}".format(i, j))

print(sum)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

# C - Sum of product of pairs
N = int(input())
A = list(map(int, input().split()))
ans = 0

for i in range(N):
  for j in range(i + 1, N):
    ans += (A[i] * A[j]) % (10 ** 9 + 7)

print(ans % (10 ** 9 + 7))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))

ans = 0
mod = 10 ** 9 + 7
for i in range(n):
    for j in range(i+1, n):
        ans += a[i] * a[j]
        ans %= mod
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7

total = 0
for i in range(N):
  for j in range(i+1, N):
    total += A[i] * A[j]

print(total % MOD)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))

total = 0
for i in range(N-1):
  sum_val = sum(A[i+1:N])
  total += A[i]*sum_val
  total %= (10**9+7)
print(total)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = list(map(int, input().split()))

total = 0 

for i in range(len(s)-1):
  for j in range(i+1, len(s)):
    total += s[i] * s[j]

print(total % (10**9 +7))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
c = list(map(int, input().rstrip().split()))
a=0
b=10**9+7
for i in range(len(c)):
    for j in range(i+1,n):
        
        a=(a%b+((c[i]%b*c[j]%b)%b)%b)%b
        
print(a)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
c = list(map(int, input().rstrip().split()))
a=0
b=10**9+7
for i in range(len(c)):
    for j in range(i+1,n):
        
        a=(a+(c[i]%b*c[j]%b)%b)%b
        
print(a)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
c = list(map(int, input().rstrip().split()))
a=0
b=10**9+7
for i in range(len(c)):
    for j in range(i+1,n):
        
        a=(a+(c[i]*c[j])%b)%b
        
print(a)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
c = list(map(int, input().rstrip().split()))
a=0
b=10**9+7
for i in range(len(c)):
    for j in range(i+1,n):
        
        f=(c[i]%b*c[j]%b)%b
        a=a+f
        
print(a%b)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
c = list(map(int, input().rstrip().split()))
a=0
b=10**9+7
for i in range(len(c)):
    for j in range(i+1,n):
        
        f=(c[i]*c[j])%b
        a=a+f
        
print(a%b)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ary_A = list(map(int, input().split()))

remain_sum = 0

sub_sum_ary = []

for j in range(N):
    sub_sum_ary.append(sum(ary_A[j + 1:N]))

for i in range(N):
    remain = (ary_A[i] * sub_sum_ary[i]) % (10**9 + 7)
    remain_sum += remain

print(remain_sum % (10**9 + 7))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
c = list(map(int, input().rstrip().split()))
a=0
for i in range(n):
    for j in range(i+1,n):
        a=a+c[i]*c[j]
print(a%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ary_A = list(map(int, input().split()))

remain_sum = 0

for i in range(N):
    sub_sum = 0
    for j in range(i):
        sub_sum += ary_A[j]

    remain = (ary_A[i] * sub_sum) % (10**9 + 7)
    remain_sum += remain

print(remain_sum % (10**9 + 7))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ary_A = list(map(int, input().split()))

remain_sum = 0

for i in range(N):
    for j in range(i):
        remain = (ary_A[i] * ary_A[j]) % (10**9 + 7)
        remain_sum += remain

print(remain_sum % (10**9 + 7))

Submission status: Time Limit Exceeded

Solution code:
n=input()
m=0
MOD = 10 ** 9 + 7
from itertools import combinations
b=combinations
a=b(map(int,input().split()),2)
for i,j in a:
    k=i*j
    m+=k%MOD
    m%=MOD
print(m)

Submission status: Time Limit Exceeded

Solution code:
n=input()
m=0
MOD = 10 ** 9 + 7
from itertools import combinations
b=combinations
a=b(map(int,input().split()),2)
for i,j in a:
    k=i*j
    m+=k
    m%=MOD
print(m)

Submission status: Time Limit Exceeded

Solution code:
n=input()
m=0
from itertools import combinations
b=combinations
a=b(map(int,input().split()),2)
for i,j in a:
    k=i*j
    m+=k
MOD = 10 ** 9 + 7
v=m%MOD
print(v)

Submission status: Time Limit Exceeded

Solution code:
n=input()
m=0
MOD = 10**9 + 7
from itertools import combinations
a=combinations(map(int,input().split()),2)
for i,j in a:
    k=i*j
    m+=k
if m<=MOD:
    print(m)
else:
    v=m%MOD
    print(v)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
pans = 0
for i in range(n):
    ans = sum(a[i+1:])
    ans *= a[i]
    ans = ans % (10**9+7)
    pans += ans
print(pans%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

nums = list(map(int, input().split()))

ans = 0
for i in range(n):
    ans += nums[i] * sum(nums[i+1:])

print(ans % (10**9+7))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

nums = list(map(int, input().split()))

ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += nums[i] * nums[j]

print(ans % (10**9+7))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
List = list(map(int, input().split()))
res=0
for i in range(N-1):
  a = List[i] % 1000000007
  for j in range(i+1,N):
    b =  List[j] % 1000000007
    res += a*b
print(res%1000000007)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
_sum = 0

for i in range(N):
  for j in range(i+1, N):
    _sum += A[i] * A[j]

print(_sum % (10**9 + 7))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = list(map(int,input().split()))
mod = pow(10,9)+7
ans = 0
for i in range(n):
    ans += A[i] * sum(A[i+1:])
    ans = ans % mod
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(v) for v in input().split()]
MOD = int(1e9 + 7)
s = 0
L = {}
for i in range(N):
    for j in range(i+1, N):
        if (A[i], A[j]) in L or (A[j], A[i]) in L:
            s = (s + L[(A[i], A[j])]) % MOD
        else:
            r = (A[i] * A[j])
            s = (s + r) % MOD
            L[(A[i], A[j])] = r
            L[(A[j], A[i])] = r

print(s)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
n = 1
ans = 0
mainus = 0
 

for i in a:
    mainus += i
    ans_a = a[n-1] * (sum(a) - mainus )
    ans += ans_a
    n += 1

MOD = 10 ** 9 + 7
ans %= MOD

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = list(map(int,input().split()))

sum_a = 0
for i in range(n-1):
	for j in range(i+1,n):
		sum_a += (A[i] * A[j])

print(int(sum_a%(1e9 + 7)))

Submission status: Time Limit Exceeded

Solution code:
# coding:utf-8

n = int(input())
a = list(map(int, input().split()))
ans = 0

for i in range(n - 1):
    cum = sum(a[i + 1:])
    ans += a[i] * cum

print(ans % (10**9 + 7))

Submission status: Time Limit Exceeded

Solution code:
# coding:utf-8
import numpy
n = int(input())
a = list(map(int, input().split()))
ans = 0

for i in range(n - 1):
    cum = numpy.cumsum(a[i + 1:])
    ans += a[i] * cum[-1]

print(ans % (10**9 + 7))

Submission status: Time Limit Exceeded

Solution code:
import itertools
import collections
import math
import sys
sys.setrecursionlimit(2000000)
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
data = [i for i in range(n)]

for i, j in itertools.combinations(data, 2):
    ans += (a[i] % mod)*(a[j] % mod) % mod

ans %= mod
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += (a[i] % mod)*(a[j] % mod) % mod

ans %= mod
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += a[i]*a[j] % mod

ans %= mod
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = I()
A = LI()
l = list(itertools.combinations(A, 2))
ans = 0
for i, j in l:
    ans += i*j
print(ans%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
MOD=10**9+7
total=0
for i in range(N-1):
  temp = 0
  for j in range (i+1,N):
    temp += A[j]%MOD
  total += A[i]*temp%MOD
print(total%MOD)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
total=0
for i in range(N-1):
  for j in range (i+1,N):
    total += A[i]*A[j]
print(total%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
#標準入力
N = int(input())
A = list(map(int, input().split()))

A = list(map(lambda x: x%(1000000000+7), A))
_sum = 0
 
for n in range(N-1):
  for i in range(n+1):
    _sum = _sum + (A[n+1] * A[i])
    _sum = _sum % (1000000000+7)
    
print(_sum)

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    As = list(map(int, input().split()))
    mod = 10**9 + 7

    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            ans += As[i] * As[j]
    ans %= mod
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
 
N = int(input())
A = np.array(list(map(int, input().split())))
 
A = A % (1000000000+7)
_sum = 0
 
for n in range(N-1):
  for i in range(n+1):
    _sum = _sum + (A[n+1] * A[i])
    _sum = _sum % (1000000000+7)
    
print(_sum)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A = list(map(int,input().split()))
mod=1000000007
ans=0
for i in range(N-1):
  for j in range(i+1,N):
    a=A[i]*A[j]
    a%=mod
    ans+=a
    ans%=mod
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A = list(map(int,input().split()))
mod=1000000007
ans=0
for i in range(N-1):
  for j in range(i+1,N):
    a=A[i]*A[j]%mod
    ans+=a
    ans%=mod
print(ans)

Submission status: Time Limit Exceeded

Solution code:
x = input()
N = int(x)
A = list(map(int,input().split()))
a = 0

for i in range(N-1):
    for j in range(N-i-1):
        a = a + A[i]*A[i+j+1]
print(a % (10**9+7))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = list(map(int, input().split()))

sum_value = 0
for i in range(n-1):
    for j in range(i+1,n):
        sum_value += nums[i]*nums[j]

print(sum_value%1000000007)

Submission status: Time Limit Exceeded

Solution code:
N=input()
A=list(map(int,input().split()))
ans=0
M=10**9+7
for i in range(len(A)-1):
    for j in range(len(A)-i-1):
        ans+=A[i]*A[i+j+1]%M
        ans%=M
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=input()
A=list(map(int,input().split()))
ans=0
for i in range(len(A)-1):
    for j in range(len(A)-i-1):
        ans+=A[i]*A[i+j+1]
        ans%=10**9+7
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
import itertools
ans = 0
for i in itertools.combinations(a, 2):
    ans += i[0]*i[1]
    ans%=10**9+7
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
num = list(map(int,input().split()))
m = 10**9 + 7
ans = 0

for i in range(n):
  sum_i = num[i] * (sum(num[i+1:n]) % m)
  ans += sum_i

print(ans%m)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = 0

for i in range(n-1):
    for j in range(i+1,n):
        ans += a[i]*a[j]
print(ans%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
MOD = 1000000007

N = int(input())
n_list = list(map(int,input().split()))

result = 0

for i in range(N):

    for j in range(N-i-1):
        result += n_list[i] * n_list[j+i+1] % MOD
        result = result % MOD

print(result)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int,input().split()))
import itertools
c = itertools.combinations(A, 2)
B=[]
a=0
for v in itertools.combinations(A, 2):
    c=v[0]*v[1]
    a=a+c
print(a%1000000007)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int,input().split()))
import itertools
c = itertools.combinations(A, 2)
B=[]
for v in itertools.combinations(A, 2):
    c=v[0]*v[1]
    B.append(c)
print(sum(B)%1000000007)

Submission status: Time Limit Exceeded

Solution code:
def func(N,A):
  result = 0
  for i in range(0,N-1,1):
    for j in range(i+1,N,1):
      result += (A[i] * A[j])
  return result % (10 ** 9 + 7)

if __name__ == "__main__":
  N = int(input())
  A = list(map(int, input().split()))
  print(func(N,A))

Submission status: Time Limit Exceeded

Solution code:
n = input()
a_list = list(map(int, input().split()))
sum_ = 0
mod = 10 ** 9 + 7
for i in range(len(a_list) - 1):
  for j in range(i + 1, len(a_list)):
    sum_ += ((a_list[i] % mod) * (a_list[j] % mod)) % mod 
print(sum_ % mod)

Submission status: Time Limit Exceeded

Solution code:
s = input()
a = list(map(int,input().split()))
mod = 1000000007
ans = 0
while True:
    l_f = a[0]
    del a[0]
    if len(a) < 1: break
    for i in a:
        ans += l_f * i
print(ans%mod)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = list(map(int, input().split()))
sum1 = sum(s)
sum2 = 0
m = 1000000007
for i in range(n):
    sum2 += ((s[i]%m)*(sum1%m - (sum(s[:i+1]))%m)%m)%m
print(sum2%m)