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())
arr_a = list(map(int, input().split()))

mod = 10**9 + 7

ans = 0
for i in range(n):
    b = sum(arr_a[i+1:])
    b = b % mod
    ans += arr_a[i] * b
    ans = ans % mod

print(ans)

Submission status: Time Limit Exceeded

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

sum_a = sum(arr_a)
mod = 10**9 + 7

ans = 0
for i in range(n):
    b = sum(arr_a[i+1:])
    b = b % mod
    ans += arr_a[i] * b
    ans = ans % mod

print(ans)

Submission status: Time Limit Exceeded

Solution code:
m = input()
a = input().split()
l = []
for i in range(int(m)):
    for w in a[i+1:]:
        l.append((a[i],w))

tmp = sum(int(n[0])*int(n[1]) for n in set(l))
print(tmp%1000000007)

Submission status: Time Limit Exceeded

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

sum_a = sum(arr_a)
mod = 10**9 + 7

ans = 0
for i in range(n):
    b = sum(arr_a[i+1:])
    ans += arr_a[i] * b
    ans = ans % mod

print(ans)

Submission status: Time Limit Exceeded

Solution code:
m = input()
a = input().split()
l = []
for i in range(int(m)):
    for w in a[i+1:]:
        l.append((a[i],w))
tmp = sum(int(n[0])*int(n[1]) for n in list(set(l)))
print(tmp%1000000007)

Submission status: Time Limit Exceeded

Solution code:
input()
a = input().split()
l = []
for i,n in enumerate(a):
    for w in a[i+1:]: l.append((n,w)) 
tmp = sum(int(n[0])*int(n[1]) for n in list(set(l)))
print(tmp%1000000007)

Submission status: Time Limit Exceeded

Solution code:
input()
a = input().split()
l = []
for i,n in enumerate(a):
    for w in a[i+1:]: l.append((int(n),int(w))) 
tmp = sum(n[0]*n[1] for n in list(set(l)))
print(tmp%1000000007)

Submission status: Time Limit Exceeded

Solution code:
input()
a: list = input().split()
l: list = []
for ii, i in enumerate(a):
    for w in a[ii+1:]:
        l.append((int(i), int(w))) 

tmp = sum(n[0]*n[1] for n in list(set(l)))
print(tmp % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
input()
a: list = input().split()
l: list = []
for ind, i in enumerate(a):
    for w in a[ind+1:]:
        l.append((int(i), int(w))) 
tmp = 0
for i in list(set(l)):
    tmp += i[0] * i[1]
print(tmp % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
input()
a: list = input().split()
l: list = []
for ind, i in enumerate(a):
    for w in a[ind+1:]:
        l.append((int(i), int(w)))
 
tmp = 0
for i in list(set(l)):
    tmp += i[0] * i[1]
if tmp < 1000000007:
    print(tmp)
    exit()
print(tmp % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
input()
a: list = [int(n) for n in input().split()]
l: list = []
for ind, i in enumerate(a):
    for w in a[ind+1:]:
        k = (i, w)
        l.append(k)
 
l = list(set(l))
tmp = 0
for i in l:
    tmp += i[0] * i[1]
if tmp < 1000000007:
    print(tmp)
    exit()
print(tmp % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
n: int = int(input())
a: list = [int(n) for n in input().split()]
l: list = []
for ind, i in enumerate(a):
    for w in a[ind+1:]:
        l.append(sorted([i, w]))
 
l = list(map(list, set(map(tuple, l))))
tmp = 0
for i in l:
    tmp += i[0] * i[1]
if tmp < 1000000007:
    print(tmp)
    exit()
print(tmp % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
n: int = int(input())
a: list = [int(n) for n in input().split()]
m = 1000000007
l: list = []
for ind, i in enumerate(a):
    for w in a[ind+1:]:
        l.append(sorted([i, w]))

l = list(map(list, set(map(tuple, l))))
tmp = 0
for i in l:
    tmp += i[0] * i[1]
print(tmp % m)

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]
print(ans%mod)

Submission status: Time Limit Exceeded

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

B=[0]*N
c=0

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

Submission status: Time Limit Exceeded

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

B=[0]*N
c=0

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

Submission status: Time Limit Exceeded

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

B=[0]*N
c=0

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

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

ans = s % 1000000007

print(ans)

Submission status: Time Limit Exceeded

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

i = 0
j = 0

while i <= len(A) - 1:
    while j <= len(A) - 1:
        if i < j:
            ans.append(A[i] * A[j] % 1000000007)
            j += 1
        else:
            j += 1
    i += 1
    j = 0

print(sum(ans) % 1000000007)

Submission status: Time Limit Exceeded

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

i = 0
j = 0

while i < len(A) - 1:
    while j <= len(A) - 1:
        if i < j:
            ans.append(A[i] * A[j] % 1000000007)
            j += 1
        else:
            j += 1
    i += 1
    j = 0

print(sum(ans) % 1000000007)

Submission status: Time Limit Exceeded

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

i = 0
j = 0

while i < len(A) - 1:
    while j <= len(A) - 1:
        if i < j:
            ans.append(A[i] * A[j])
            j += 1
        else:
            j += 1
    i += 1
    j = 0

print(sum(ans) % 1000000007)

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(1, N):
    for j in range(i+1, N+1):
        # print("{}:{}".format(i, j))
        ans += A[i-1] * A[j-1]
        ans %= MOD
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(i)%1000000007 for i in input().split(' ')]
ans = 0

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

print(ans%1000000007)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li_a = list(map(int, input().split()))
answer = 0
mo = (10 ** 9) + 7
for idx, a in enumerate(li_a):
    answer += (a * sum(li_a[idx + 1:]))
print(answer % mo)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lst = [ int(i) for i in input().split() ]
count = 0
for i in range(len(lst)):
    c = 0
    for j in range(i+1, len(lst)):
        c += lst[j]
    count += c * lst[i]
    
mod = 10**9 +7
if count >= mod:
    print(count%mod)
else:
    print(count)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(n):
  ans = ans + s[i] * (sum(s[i+1:])%(10**9+7))

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

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(n):
  x = s.pop(-1)
  ans = ans + x * sum(s)

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

Submission status: Time Limit Exceeded

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

ans = 0
temp = 0

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

n = input_one_number()
a = input_multiple_number_as_list()

ssum =0
mod = 10**9+7
import itertools as itr
for i in itr.combinations(range(len(a)),2):
	ssum += a[i[0]]*a[i[1]]
	ssum %= mod
print(ssum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Al = input().split()
A = list( map((lambda x: int(x)), Al))
num = 0
ma = 10**9 + 7

for i in range(N):
  num = (num + A[i]*sum(A[i+1:])) % ma

print(num)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Al = input().split()

A = []
for i in range(N):
  A.append(int(Al[i]))

num = 0
ma = 10**9 + 7

for i in range(N):
  num = (num + A[i]*sum(A[i+1:])) % ma

print(num)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Al = input().split()

A = []
for i in range(N):
  A.append(int(Al[i]))

num = 0
ma = 10**9 + 7

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

print(num)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Al = input().split()

A = []
for i in range(N):
  A.append(int(Al[i]))

num = 0

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

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

Submission status: Time Limit Exceeded

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

num = 0

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

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

Submission status: Time Limit Exceeded

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

total = 0
n = sum(list(range(1,N,1)))
# print(n)
first = 0
second = 0
for i in range(n):
  total += i_j_list[first] * i_j_list[second+1]
  if (second + 1) == (N - 1):
      second = first + 1
      first += 1 
  else: 
      second += 1
      
ans = total % (10**9 + 7)
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np
import itertools
readline = sys.stdin.readline

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

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

ans = np.mod(ans, 1e+9 + 7)

print(f"{ans:.0f}")

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-1):
    ans += A[i]*sum(A[i+1:])
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()))
import itertools
B = list(itertools.combinations(A,2))
print(sum (list(map(lambda x: x[0] * x[1], B))) % (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()))
import itertools
B = list(itertools.combinations(A,2))
ans = 0
for i in B:
    ans += i[0]*i[1]
print(ans % (10**9+7))

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
numbers = input().split()
numbers = list(map(int, numbers))
sums = 0
total= 0

for i in range(0, x):
    sums = sum(numbers[i+1:x])
    #print(sums)
    total = total + numbers[i]*sums


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

mod = 10 ** 9 + 7


N = int(input().rstrip())
As = list(map(int, input().rstrip().split()))
ans = 0
add = 0

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

Submission status: Time Limit Exceeded

Solution code:

mod = 10 ** 9 + 7


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

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

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

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

sum %= mod
print(sum)

Submission status: Time Limit Exceeded

Solution code:
# input here
_INPUT = """\
4
141421356 17320508 22360679 244949
"""
"""
K = int(input())
H, W, K = map(int, input().split())
a = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(N)]
p = tuple(map(int,input().split()))
"""
def main():
    n = int(input())
    a = list(map(int, input().split()))

    sum1 = 0
    for i in range(len(a)):
        mult = a[i] * sum(a[i+1:])
        sum1 += mult

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


if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools
    from collections import deque

    # sys.stdin = io.StringIO(_INPUT)
    main()

Submission status: Time Limit Exceeded

Solution code:
# input here
_INPUT = """\
4
141421356 17320508 22360679 244949
"""
"""
K = int(input())
H, W, K = map(int, input().split())
a = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(N)]
p = tuple(map(int,input().split()))
"""
def main():
    n = int(input())
    a = list(map(int, input().split()))
    comb = list(itertools.combinations(a, 2))
    sum = 0
    for i in range(len(comb)):
        mult = comb[i][0] * comb[i][1]
        sum += mult

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


if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools
    from collections import deque

    # sys.stdin = io.StringIO(_INPUT)
    main()

Submission status: Time Limit Exceeded

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

ans = 0

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

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(N-1):
    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 = [int(i) for i in 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())
al = list(map(int,input().split()))
sss=0
for i in range(N):
    sss+=al[i]*sum(al[i+1:N])
print(sss%1000000007)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

ans = 0
for i, j in itertools.combinations(a,2):
    ans = (ans + i*j)%(1e9+7)


print(int(ans))

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(N):
    for j in range(N-i-1):
        ans += As[i]*As[j+i+1]
        if ans >= 10**9+7:
            ans = ans%(10**9+7)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
al = list(map(int,input().split()))
sss=0
for i in range(N):
    sss+=(sum(al[0:i])%1000000007)*al[i]
print(sss%1000000007)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
al = list(map(int,input().split()))
sss=0
for i in range(N):
    sss+=sum(al[0:i])%1000000007*al[i]
print(sss%1000000007)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
al = list(map(int,input().split()))
sss=0
for i in range(N):
    sss+=al[i]*sum(al[0:i])
    sss%=1000000007
print(sss)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
al = list(map(int,input().split()))
sss=0
for i in range(N):
    sss+=al[i]*sum(al[0:i])
print(sss%1000000007)

Submission status: Time Limit Exceeded

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

ans = 0

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

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

Submission status: Time Limit Exceeded

Solution code:
N= int(input())
al=list(map(int,input().split()))
sss=0
for i in range(N):
    for j in range(i):
        sss+=al[j]*al[i]

print(sss%1000000007)

Submission status: Time Limit Exceeded

Solution code:
def execute(N, A):
    dst = 0
    for i in range(N-1):
        for j in range(i+1, N):

            dst += A[i] * A[j]

    return dst % (10**9+7)

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

    print(execute(N, A))

Submission status: Time Limit Exceeded

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

total=0

for i in range(n-1):
  for j in range(n-i-1):
    total=total+a[i]*a[i+j+1]%1000000007
    
print(total% 1000000007)

Submission status: Time Limit Exceeded

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

total=0

for i in range(n-1):
  for j in range(n-i-1):
    total=total+a[i]*a[i+j+1]%1000000007
    total=total % 1000000007
    
print(total)

Submission status: Time Limit Exceeded

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

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):
            tmp = a[i]*a[j]
            ans += tmp

m = 10**9 + 7

ans = ans % m

print(ans)

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)

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:
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:
MOD = 10**9 + 7
def main(N, A_list):

    result = 0


    for i in range(N):
        for t in range(i+1, N):
            left  = A_list[i]
            right = A_list[t]
            result += (left * right) % MOD
    print(result % MOD)

if __name__ == '__main__':
    N = int(input())
    A_list = [ int(i) for i in input().split()]
    main(N, A_list)

Submission status: Time Limit Exceeded

Solution code:
def main(N, A_list):
    MOD = 10**9 + 7

    result = 0


    for i in range(N):
        for t in range(i+1, N):
            left  = A_list[i] % MOD
            right = A_list[t] % MOD
            result += (left * right) % MOD
    print(result % MOD)

if __name__ == '__main__':
    N = int(input())
    A_list = [ int(i) for i in input().split()]
    main(N, A_list)

Submission status: Time Limit Exceeded

Solution code:
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=int(input())
A=input_array()
ans=0
for i in range(n-1):
	for j in range(i,n):
		if i!=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()]
s = 0
for i in range(N-1):
    for j in range(i+1, N):
        s += (A[i] * A[j]) % (10**9+7)
print(s%(10**9+7))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(sum % mod)

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(N - i - 1):
        sum += A[i] * A[N -1 - j]

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

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

Submission status: Time Limit Exceeded

Solution code:
import itertools

n = input()
l = map(int, input().split())

c = itertools.combinations(l, 2)

ans = 0

for i,j in c:
    ans = (ans + i * j) % (10 ** 9 + 7)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())  # 個数
A = np.array([int(i) for i in input().split()], dtype=np.int64)  # 整数

sum_j = [sum(A[i + 1:N]) % 1000000007 for i in range(N - 1)]
mod_A = np.dot(A[0:N-1], sum_j) % 1000000007

print(mod_A)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())  # 個数
A = np.array([int(i) for i in input().split()], dtype=np.int64)  # 整数

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

print(sum_a % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())  # 個数
A = [int(i) % 1000000007 for i in input().split()]  # 整数

sum_A = 0
for i in range(N-1):
    sum_A += A[i] * sum(A[i+1:N]) % 1000000007

print(sum_A % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())  # 個数
A = [int(i) for i in input().split()]  # 整数

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

print(sum % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())  # 個数
A = [int(i) for i in input().split()]  # 整数

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

print(sum % 1000000007)

Submission status: Time Limit Exceeded

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

ans = total - cnt
ans %= mod
ans *= pow(2, mod - 2)
ans %= mod
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=input().split()
A=[int(i) for i in A]
S=0
A_sum=[]
for i in range(N):
    sum=0
    for j in range(i+1,N):
        sum+=A[j]
    A_sum.append(sum)
    


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

print(S%(pow(10,9)+7))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#-*- Coding: utf-8 -*-

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

y = 0
for i in range(N-1):
    for j in range(N):
        if i >= j:
            continue
        else:
            #print(A[i], A[j])
            x = A[i] * A[j]
            y += x
print(int(y % (7+1e+9)))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
 
lst = input().split()
 
for i in range(N):
   lst[i] = int(lst[i])
 
sum = 0
 
for i in range(N - 1):
   for j in range(i + 1, N):
      sum += lst[i] * lst[j]
 
s = 10**9 + 7
 
if sum < s:
   print(sum)
else:
   print(sum % s)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A = input().split()

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

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

Submission status: Time Limit Exceeded

Solution code:
def solve(N, As):
    total = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            total += As[i] * As[j]
    ans = total % (10 ** 9 + 7)
    print(ans)


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split()))
    solve(N, As)

Submission status: Time Limit Exceeded

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def sumprod(A):
    ret = 0
    n = len(A)
    for i in range(n):
        for j in range(i+1, n):
            ret += A[i]*A[j]
    return ret % (10**9 + 7)

def main():
    n = int(input())
    A = [*map(int, input().split())]
    print(sumprod(A))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A = input().split()

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

import itertools

seq=[x for x in range(0,n)]
l=list(itertools.combinations(seq,2))

ans=0

for ll in l:
  ans += a[ll[1]] * a[ll[0]]

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a_l = list(map(int, input().split()))
sum = 0

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

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

Submission status: Time Limit Exceeded

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

def SumOfProductParis(n):
    if n == 0:
        return 0
    elif n == 1:
        return A[0]
    else:
        result = 0
        for i in range(0, n-1):
            for j in range(i+1, n):
                result += A[i]*A[j]
        return result%(10**9+7)

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

print(SumOfProductParis(N))

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

ans = 0

B = list(itertools.combinations(A,2))

for i in range(len(B)):
    ans += (B[i][0] * B[i][1]) % MOD

ans %= MOD

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

ans = 0

B = list(itertools.combinations(A,2))

for i in range(len(B)):
    ans += B[i][0] * B[i][1]

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

#print(B)
#print(len(B))
print(ans)

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
alist=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 += (alist[i]*alist[j])%mod
        ans = ans%mod
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

mod = 1000000007
sum = 0
N = int(input())
A = list(map(int, input().split()))
for v in itertools.combinations(A, 2):
    sum += v[0] * v[1]
print(sum%mod)

Submission status: Time Limit Exceeded

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

for i in range(N):
    A[i] = int(A[i])

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

print(ans % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
import itertools
n = int(input())
l = list(map(int,input().split()))
a = list(itertools.combinations(l,2))
r=[]
x = [(z*q) for z,q in a]
print(sum(x)%(10**9+7))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(n-1):
    tmp = lst[i] * sum(lst[i+1:])
    ans = (ans + tmp) % mod

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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