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:
s = int(input())

num = input()
num = num.split()
 
for i in range(s):
    num[i] = int(num[i])

ans = []
count = 0
while count != s-1:
    k = num[0]
    for j in range(s - count -1):
        ans.append( k * num[j+1])
    num.pop(0)
    count = count +1

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

Submission status: Time Limit Exceeded

Solution code:
#abc177_C_4_掛け算の時点で計算を挟む、最後のあまりは最後の時に
int_n = int(input())
list_tmp = list(map(int, input().split()))
 
int_sum = 0
int_divide = (10**9) + 7
 
for i in range(0, len(list_tmp) - 1):
  for j in range(i + 1, len(list_tmp)):
    int_sum = (int_sum + ((list_tmp[i]%int_divide) * (list_tmp[j]%int_divide)))
    
int_sum = int_sum%int_divide
print(int_sum)

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]
    total = total % (10**9 + 7)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
an = list(map(int, input().split()))
m = 10**9 + 7
summary = 0
for i in range(0, n-1):
    for j in range(i+1, n):
#         if i == j: continue
#         print(i, j)
        summary += (an[i] * an[j]) % m
#         print(summary)
print(summary % m)

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

result = 0

for a, b in itertools.combinations(A, 2):
    result += a * b % mod
    result = result % mod

print(result)

Submission status: Time Limit Exceeded

Solution code:
n = input()
a_list = [int(a) for a in input().split(" ")]

a_len = len(a_list)
max = 10**9 + 7

sum = 0
for i in range(0, (a_len-1)):
  for j in range(i+1, a_len):
    sum += a_list[i] * a_list[j]

sum = sum % max
print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
s = 0
for i in range(n-1):
    for j in range(n):
        if i >= j:
            continue
        s += a[i] * a[j]
print(s % 1000000007)

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]) % 1000000007) + total) % 1000000007

print(total)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
An_input = input().split()
An = [int(s) for s in An_input]

#print(An)
A = An[0] + An[1]
#print(A)

cnt = 0
M = 10**9 + 7

for i in range(0, N-1):
    #print(i)
    for l in range(1, N-i):
        cnt += An[i] * An[i+l]
        #print(An[i], An[i+l])
        #print(cnt)

ans = cnt % M
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
num_list = [int(i) for i in input().split()]
ans = 0
mod = 10 ** 9 + 7

while len(num_list) > 1:
    x = num_list[0] % mod
    num_list.remove(x)
    ans += (x * (sum(num_list) % mod)) % mod

print (ans % mod)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
data = list(map(int, input().split()))
sum = 0

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A_list = list(map(int, input().split()))
A_list.sort()
A_list.insert(0,0)
sum = 0
for i in range(1, N):
    for j in range(i + 1, N + 1):
        sum += (A_list[i] * A_list[j]) 
        sum = sum % 1000000007
print(sum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = input().split()
s = 0
for i in range(N-1):
    for h in range(i+1,N):
        s =s+ int(A[i])*int(A[h])

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

print(s)

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-1):
  ans += a[i] * sum(a[i+1:])
  ans %= mod
print(ans)

Submission status: Time Limit Exceeded

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

print(int(rest%mod_num))

Submission status: Time Limit Exceeded

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

for x in range(len(A)):
    for y in range(x+1, len(A)):
        ans += A[x]*A[y]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
num=input().split()
for i in range(n):
  num[i]=int(num[i])
i=0
pro=0
while i<n:
  j=i+1
  while j<n:
    pro+=(num[i]*num[j])
print(num%1000000007)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ls = list(map(int, input().split()))
MOD = 10 ** 9 + 7

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int,input().split()))
from itertools import combinations
ans=0
for i in combinations(A,2):
    #print(i)
    ans+=i[0]*i[1]
print(divmod(ans,10**9+7)[1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

import numpy as np

n = int(input().strip())
l = list(map(int, input().split()))
l = np.array(l)

tot = 0
for i in range(n):
    tot += (l[i] * (np.sum(l[i+1:n], dtype = 'int64') % (10**9 + 7))) % (10**9 + 7)
    '''
    if tot >= 10**9 + 7:
        tot %= (10**9 + 7)
    '''

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

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):
    ans += A[i]*A[j]%mod
print(ans%mod)

Submission status: Time Limit Exceeded

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

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


print(count%MOD)

Submission status: Time Limit Exceeded

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

tmp_sum = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        # print(A[i] * A[j])
        tmp_sum += (A[i] * A[j]) 
print(tmp_sum % 1000000007)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#n = 4
#a = [141421356, 17320508, 22360679, 244949]
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, n):
        if i == j:
            continue
        ans += (a[i]*a[j])
print(ans%MOD)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#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]%(10**9+7)*A[j]%(10**9+7))%(10**9+7)
        ans = ans%(10**9+7)
print(ans)

Submission status: Time Limit Exceeded

Solution code:

N = int(input())
li = list(map(int, input().split()))
MOD_NUMBER = 10**9+7
ans = 0
for idx in range(len(li)-1):
    ans += li[idx] * sum(li[idx+1:])

print(ans % MOD_NUMBER)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A = list(map(int, input().split()))
all=0
for index,i in enumerate(A):
    for k in range(len(A)-index-1):
        all+=i*A[k+index+1]
q, mod = divmod(all, 10**9+7)
print(mod)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(input().split())
B = [int(a) for a in A]
x = 10**9+7
summation = sum((B[i] * (sum(B[j] for j in range(i+1,N)))) for i in range(N-1)) % x
print(summation)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
alist = list(map(int, input().split()))
Sum_a = 0
for i in range(N):
  Sum_j = 0
  for j in range(i+1, N):
    Sum_j += alist[j]
  Sum_j = Sum_j
  Sum_a += (alist[i] * Sum_j) % (1e9+7)
print(int(Sum_a % (1e9+7)))

Submission status: Time Limit Exceeded

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

import copy
ans = 0

for i in range(N-1):
    B = copy.copy(A)
    del B[:i+1]
    for j in range(len(B)):
        ans += A[i] * B[j] % MOD
        ans = ans % MOD
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
ans=0
for i in range(n-1):
    for j in range(1+i,n):
        ans+=a[i]*a[j]

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

Submission status: Time Limit Exceeded

Solution code:
D = 10 ** 9 + 7
N = int(input())
L= list(map(int, input().split()))

ans = L[0] * L[1] % D
for n in range(2,N):
  for l in range(n):
    ans += L[n] * L[l] % D

print(ans % D)

Submission status: Time Limit Exceeded

Solution code:
import math

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

for i in range(N-1):
    for j in range(i+1,N):
        #print("i="+str(i)+"\tj="+str(j)+"\t[i]="+str(A[i])+"\t[j]="+str(A[j]))
        ans+=A[i]*A[j]
print(ans%((10**9)+7))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a =[int(x) for x in input().split()]
ans = 0
ans2 = 0
b = 10**9 + 7
for index,i in enumerate(a):
    for j in a[index+1:]:
        ans2 = (ans2 + i * j) % b
        ans =  (ans + ((i%b) * j))%b
print(ans)

Submission status: Time Limit Exceeded

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

def mod(x):
	return x % 1000000007

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

print(s)

Submission status: Time Limit Exceeded

Solution code:
n = input()
a_list = [int(a) for a in input().split(" ")]

max = 10**9 + 7

sum = 0
for i in range(0, len(a_list)-1):
  for j in range(i+1, len(a_list)):
    sum += a_list[i] * a_list[j]
    sum = sum % max
print(sum)

Submission status: Time Limit Exceeded

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

A_l = [i for i in A_l if i != 0]

for i in range(len(A_l)):
    for j in range(i+1,len(A_l)):
        a_sum = a_sum + (A_l[i] * A_l[j])
print(a_sum % (10**9+7))

Submission status: Time Limit Exceeded

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

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

res = 0

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

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()))

import itertools

total = 0

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

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

Submission status: Time Limit Exceeded

Solution code:
def multmod(a,b,m):
  ans = 0
  a = a % m
  
  while b:
    if (b & 1): # odd
      ans = (ans + a) % m
    
    a = (2 * a) % m
    b >>= 1 # b = b / 2
    
  return ans


n = int(input())
S = [int(a) for a in input().split()]
divisor = 10**9 + 7
tot = 0
for i in range(n-1):
  for j in range(i+1,n):
    
    tot += multmod(S[i],S[j],divisor)
    if tot >= divisor:
      tot = tot % divisor
    
print(tot)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
mod = 10**9 + 7
n = int(input())
A = list(map(lambda x: int(x) % mod, input().split()))

out = 0
for i in range(n - 1):
    for j in range(n - i - 1):
        k = i + j + 1
        # print(A[i], A[k])
        out += (A[i] * A[k])
        out %= mod
print(out)

Submission status: Time Limit Exceeded

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

m = 10 ** 9 + 7
def main():
    r = 0
    for i in range(n - 1):
        r += a[i] * sum(a[i+1:])
    
    print(r % m)
    return

main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import itertools

n = int(input())
num_list = list(map(int, input().split()))

mod = (10**9)+7
comb = list(itertools.combinations(num_list, 2))
sum = 0
for tuple in comb:
    tmp = (tuple[0]*tuple[1])%mod
    sum += tmp

ans = sum%mod
print(ans)

Submission status: Time Limit Exceeded

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

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):
    p = 10**9+7
    A = a[i]%p
    B = a[j]%p
    ans += A*B
print(ans%p)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    import math
    n = int(input())
    # a_n = [-1] * (n + 1)
    a_n = [-1]
    hoge = list(map(int, input().split()))
    a_n.extend(hoge)
    sum_ = 0
    # for i in range(1, n):
    #     for j in range(i + 1, n + 1):
    #         sum_ += (a_n[i] * a_n[j]) % (10E08 + 7)
    # print(int(sum_ % (10E08 + 7)))
    for i, a_i in enumerate(a_n):

        if i == 0:
            continue
        for j in range(i + 1, n + 1):
            sum_ += (a_i * a_n[j]) % (10E08 + 7)
    print(int(sum_ % (10E08 + 7)))
resolve()

Submission status: Time Limit Exceeded

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

S = [0 for _ in range(N+1)]
mod = 1000000007

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

print(int(S[N-1] % mod))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = [int(x) for x in input().split()]
total = 0

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

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

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(N-1):

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

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

Submission status: Time Limit Exceeded

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

mod = 10**9 + 7
a = 0
for i in range(N):
    a += sum(A[:i]) * A[i]
    a %= mod
print(a)

Submission status: Time Limit Exceeded

Solution code:
#ABC177  C
import itertools
n = int(input())
a = list(map(int, input().split()))
mod = 1000000007

sum = 0
for i in itertools.combinations(a, 2):
  sum += i[0]*i[1] % mod
ans = sum % mod
print(ans)

Submission status: Time Limit Exceeded

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

mod = 10**9 + 7
ans = 0

for x in range(m-1):
  if a[x] % mod != 0:
    tmp = sum(a[x+1:m])
    ans += a[x] * tmp

print(ans%mod)

Submission status: Time Limit Exceeded

Solution code:
#abc177_C_3_掛け算の時点で計算を挟む
int_n = int(input())
list_tmp = list(map(int, input().split()))
 
int_sum = 0
int_divide = (10**9) + 7
 
for i in range(0, len(list_tmp) - 1):
  for j in range(i + 1, len(list_tmp)):
    int_sum = (int_sum + ((list_tmp[i]%int_divide) * (list_tmp[j]%int_divide)))%int_divide
    
print(int_sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lista = [int(x) for x in input().split()]

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(input().split())
B = [int(a) for a in A]
x = 10**9+7
summation = sum((B[i] * (sum(B[j] for j in range(i+1,N)) % x)) % x for i in range(N-1)) % x
print(summation)

Submission status: Time Limit Exceeded

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

result = 0
for i in range(len(As)-1):
    result+=As[i]*sum(As[i+1:])
print(result%(1*10**9+7))

Submission status: Time Limit Exceeded

Solution code:
#n = 4
#a = [141421356, 17320508, 22360679, 244949]
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, n):
        if i == j:
            continue
        ans += (a[i]*a[j])
        ans %= MOD

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
N = int(input())
A = list(map(int, input().split()))
_sum = 0
k = 10**9+7
com = combinations(A,2)
for AA in com:
    _sum += ((AA[0]%k)*(AA[1]%k))%k
    _sum %= k
print(_sum%k)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

    mod = 10 ** 9 + 7
    ans = 0

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

    print(ans)

if __name__ == '__main__':
    abc177_c()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

A_sum_list = [A_list[N-1]]
ans = A_list[N-1]*A_list[N-2]

for i in range(N-1, 1, -1):
    sum_temp = A_sum_list[0] + A_list[i-1]
    A_sum_list.insert(0, sum_temp)
    ans += (sum_temp * A_list[i-2])

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

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(len(L)-1):
    ans += L[i] * sum(L[i+1:])
    
print(ans % (10**9 + 7))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
SUM = 0
for i in range(1,N):
    for j in range(i):
        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()))
m = 1000000007
s = 0
for i in range(n):
    s += a[i] * (sum(a[i + 1:n]) % m)
print(s % 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(n-i-1):
    ans = (ans + a[i]*a[i+j+1]) % (10**9 + 7)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#d,t,s=map(int,input().split())
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]%(10**9+7))*(A[j]%(10**9+7))
print(ans%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
an = [int(num)  for num in input().split()]

answer = 0
for i in range(len(an)):
  answer +=  an[i] * sum(an[i+1:])
print(answer%1000000007)

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 = ans % (10**9+7)
print(ans)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
S = [0 for i in range(N-1)]

for i in range(N-1):
    K = sum(A[i+1:])
    S[i] = A[i]*K

ans = sum(S)%(10**9+7)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(x) for x in input().split()]

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

ans = ans % 1000000007
print(ans)

Submission status: Time Limit Exceeded

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


for i in range(N):
  for j in range(i,N):
    s += a[i]*a[j]
for i in range(N):
  s -= a[i]*a[i]
while s >= 10**9 +7:
  s = s % (10**9 +7)
print(s)

Submission status: Time Limit Exceeded

Solution code:

import itertools


N = int(input())
li = list(map(int, input().split()))
MOD_NUMBER = 10**9+7
ans = 0
for idx in range(len(li)-1):
    ans += li[idx] * sum(li[idx+1:])

print(ans % MOD_NUMBER)

Submission status: Time Limit Exceeded

Solution code:
'''
Contest 177 - Task C


'''

def compute(nums):
    size = len(nums)
    vals = 0
    for i in range(size):
        for j in range(i, size):
            if i!=j:
                # print(f"{nums[i]} * {nums[j]} + ")
                vals += (nums[i]*nums[j])
    return int(vals % (1e9+7))

if __name__ == "__main__":
    size = int(input())
    nums = list(map(int, input().split(" ")))
    print(compute(nums))

Submission status: Time Limit Exceeded

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

for i in range(n):
    for j in range(i+1,n):
        keisu[j] += a[i]


for i in range(n):
    ans += a[i] * keisu[i]

        
        

print(ans%(1000000000+7))

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:
import itertools
import math

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

ans = 0

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

print(ans % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import itertools as it

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

combinations_lis = list(it.combinations(a, 2))
#print(combinations_lis)

sum = 0
for i in range(len(combinations_lis)):
    sum += combinations_lis[i][0] * combinations_lis[i][1]
print(sum % (10 ** 9 + 7))

# sum = 0
# for i in range(n):
#     sum += 1 / a[i]
#print(sum)

# ans = int(sum * np.prod(a))
# print(ans % (10 ** 9 + 7))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
len_a = len(a)
range_a = range(len_a)
result = []

for i in range_a:
    for j in range_a:
        if i < j:
            result.append(a[i] * a[j])

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, *A = map(int, open(0).read().split())

MOD = 10 ** 9 + 7

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

Submission status: Time Limit Exceeded

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

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):
    A = a[i]
    B = a[j]
    ans += A*B
    ans %= (10**9+7)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
alist = list(map(int, input().split()))
Sum_a = 0
for i in range(N):
  Sum_j = 0
  for j in range(i+1, N):
    Sum_j += alist[j]
  Sum_j = int(Sum_j % (1e9+7))
  Sum_a += alist[i] * Sum_j
print(int(Sum_a % (1e9+7)))

Submission status: Time Limit Exceeded

Solution code:
def main():
    number = int(input())
    num_list = list(map(int, input().split()))
    total = sum([num_list[i]*num_list[j] for i in range(number) for j in range(i+1, number)])
    #div = total // (10**9 + 7)
    #print(total - div * (10**9 + 7))
    print(total % (10**9 + 7))
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
c = int(input())
a = list(map(int,input().split()))
b = [] + a
n = 0
result = 0
while n < c:
    b.pop(0)
    result += sum(b) * a[n]
    n += 1
print(int(result%1000000007))

Submission status: Time Limit Exceeded

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

for v in itertools.combinations(A, 2):
    total += v[0]*v[1]
    #print(v)
print(total%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
num=input().split()
answer=0
for x in range(len(num)-1):
    num[x]=int(num[x])
    for y in range(x+1,len(num)):
        num[y]=int(num[y])
        answer+=num[x]*num[y]
print(answer%(1000000007))

Submission status: Time Limit Exceeded

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

    mod_value = 10**9 + 7
    sum_ = 0
    for i in range(len(A)-1):
        sum_ = sum_ + A[i]*sum(A[i+1:]) % mod_value
    print(sum_ % mod_value)
main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(input().split())
B = [int(a) for a in A]
x = 10**9+7
summation = sum((B[i] * (sum(B[j] for j in range(i+1,N)) % x)) % x for i in range(N-1)) % x
print(summation % x)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

ini = [a[i]*sum(a[i+1:]) for i in range(n)]
print(sum(ini)%(10**9+7))

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 = (ans % mod + A[i]*A[j] % mod) % mod
print(ans)

Submission status: Time Limit Exceeded

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

mod = 10 ** 9 + 7

S = 0
for x in range(N):
    for y in range(1, N - x, 1):
        S = (S + A[x] * A[x + y]) % mod

print(S)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a=int(input())

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

sum=0

for i in range(a-1):
  for j in range(i+1,a):
    sum=sum+d[i]*d[j]

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

Submission status: Time Limit Exceeded

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

for i in range(n-1):
    for j in range(i+1, n):
            sumpro += a[i]*a[j]
            
print(sumpro%mod)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import permutations, combinations, product
import numpy as np

N = int(input())
A = list(map(int, input().split()))
S = np.array(list(combinations(A,2)))
M = 10**9 + 7

cnt = sum(np.product(S, axis=1)) % M

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
size = int(input())
arr = [int(i) for i in input().split()]

sum=0;
for i in range(0, size):
  for j in range(i+1, size):
    sum = sum + int(arr[i])*int(arr[j])
  

print(sum%1000000007)

Submission status: Time Limit Exceeded

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

print(int(rest%mod_num))

Submission status: Time Limit Exceeded

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

s = 0

m = 1000000007

for i in range(n):

    if i == n-1:
        pass
    else:
        for j in range(i+1, n):
            s += a[i] * a[j]

s = s % m

print(s)

Submission status: Time Limit Exceeded

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

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

print(sum_aiaj % 1000000007)

Submission status: Time Limit Exceeded

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

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