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=list(map(int,input().split()))
s=0
for i in range(n-1):
    for j in range(i+1,n):
        s=s+arr[i]*arr[j]
print(s%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
def findProductSum(A): 
    n=len(A)
    product = 0
    for i in range (n): 
        for j in range ( i+1,n): 
            product = product + A[i]*A[j] 
    return (product)%(1000000007) 
b=int(input())
A=list(map(int,input().split()))
print(findProductSum(A))

Submission status: Time Limit Exceeded

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

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 = 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(n-1):
    for j in range(i+1, n):
        s += (a[i] * a[j])
        s %= (10**9 + 7)

print(s)

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

print(ans)

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

Submission status: Time Limit Exceeded

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

lst = []
for i in range(n):
        lst.append((sum(a_lst) - sum(a_lst[: i + 1])) % (10 ** 9 + 7))

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-08-29 21:20:05 +0900
# LastModified: 2020-08-29 21:22:11 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    A = list(map(int, input().split()))
    amari = 1000000007
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            ans += A[i]*A[j]%amari
            ans %= amari
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

N = int(input())
A = list(map(int, input().split()))
ref = list(combinations(A, 2))
res = 0

for i in range(len(ref)):
  a, b = ref[i]
  res += ((a * b) % (10 ** 9 + 7))
print(res % (10 ** 9 + 7))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
summ = 0
answer = 0
for i in range(N):
    for l in range(i):
        summ += A[l] * A[i]
answer = summ % 1000000007
print(answer)

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(len(a)-1):
    for j in range(i+1, len(a)):
        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()))
MOD = 10**9 + 7
A.sort()
ans = 0
for i in range(N):
    for j in range(i+1,N):
        if A[i] > A[j]:
            continue
        ans += A[i] * A[j] % MOD

print(ans % MOD)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Ans = 0

for i in range(len(L)):
    for j in range(i+1,len(L)):
        #print(L[i] * L[j])
        Ans += (L[i] * L[j])%(10**9+7)
        #Ans += L[i] * L[j]
        #if Ans >= 10**9+7:
            #Ans = Ans%(10**9+7)
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(len(A)-1):
  for j in range(i+1,len(A)):
    ans = (ans + A[i]*A[j])%1000000007

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
d = 10 ** 9 + 7
n = int(input())

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

s = 0
for i in range(n):
    b = 0
    for j in range(i + 1,n):
        b += a[j]
        b %= d
    c = a[i] % d
    s += c * b
    s %= d

print(s)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
lst=list(map(int,input().split()))
total=0
for i in range(n):
  temp=0
  for j in range(i+1, n):
    temp+=lst[j]
  total+=lst[i]*temp
print(total%(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(n-1):
    for j in range(i+1, n):
        ans += A[i] * A[j]

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

Submission status: Time Limit Exceeded

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

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
cnt = 0
for x,y in combinations(A,2):
    z = x * y % mod
    cnt += z
print(cnt % mod)

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

Submission status: Time Limit Exceeded

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

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(range(n), 2):
    ans += (a[i] * a[j]) % (10**9+7)

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

Submission status: Time Limit Exceeded

Solution code:
def solution(A):
    ret = 0
    for i in range(1, len(A)):
        v = (sum(A[i:]) % (10**9 + 7)) * A[i-1]
        ret += v
        ret %= (10**9 + 7)
    return ret

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

Submission status: Time Limit Exceeded

Solution code:
def li():
    return [int(x) for x in input().split()]

N = int(input())
A = [0] + li()
d = 10**9 + 7

total = 0

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

print(total)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())
data = list(map(int,input().split(' ')))

mod = (10**9)+7

out=0
for i in range(n-1):
    d = np.array(data[i+1:])
    out += sum(data[i]*d)
    out %= mod

print(out)

Submission status: Time Limit Exceeded

Solution code:
import sys
from itertools import combinations

input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))
B = list(combinations(A,2))
sum = 0
for i in range(len(B)):
    sum += B[i][0]*B[i][1]

print(sum%1000000007)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]


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

    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
MOD = 10**9 + 7

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

res = 0

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

print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
MOD = 1e9 + 7
N = int(input())
A = list(map(int, input().split()))
c = 0
for i in range(N):
    for j in range(i + 1, N):
        if i == j:
            continue
        c += (A[i] % MOD) * (A[j] % MOD)
        c %= MOD
print(int(c))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
prime=(10**9)+7
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])%prime
        ans=ans%prime

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
sum_j = 0

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

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

Submission status: Time Limit Exceeded

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

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):
  for j in range(i+1,n): ans += a[i]*a[j]
print(ans % mod)

Submission status: Time Limit Exceeded

Solution code:
import itertools as it

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

sum=0
for ai,aj in it.combinations(A,2):
  sum+=ai*aj
  while sum>10**9+7:
    sum-=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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

Submission status: Time Limit Exceeded

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

sum = 0
mod = 1000000007
for i in range(n-1) :
  for j in range(n-i-1) :
    sum += a[i] * a[i+j+1] % mod

result = sum % mod
print(result)

Submission status: Time Limit Exceeded

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

MOD = 10**9 + 7

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

print(res % MOD)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

for i,j in itertools.combinations(A, 2):
        ans += i * j
    
print(ans % 1000000007)

Submission status: Time Limit Exceeded

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

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

print(ans % mod)

Submission status: Time Limit Exceeded

Solution code:
input_N = input()
N = int(input_N)
a_str = input().split()
a_int = []
sum = 0
for a in a_str:
  a_int.append(int(a))
for i in range(N):
  for j in range(N-i-1):
    sum += a_int[i] * a_int[i+j+1]
print(sum%(pow(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]

print(ans % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
def main():
    _ = int(input())
    A = [int(x) for x in input().split()]
    mod = 10 ** 9 + 7

    ans = 0
    for index, i in enumerate(A):
        ans += i * sum(A[index + 1:]) % mod
    print(ans % mod)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def binpow(a,b,m):
    
    a %= m
    res = 1
    while (b > 0):
        if (b & 1):
            
            res = res * a % m
        a = a * a % m
        b >>= 1
    
    return res


n=input()
n=int(n)
Sum=0
arr=list(map(int,input().rstrip().split()))
for i in range(len(arr)):
    for j in range(i+1,len(arr)):
        d=arr[i]*arr[j]
        Sum=Sum+(binpow(d,1,1000000007))
        

print(binpow(Sum,1,1000000007))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(N):
    for j in range(i+1,N):
        ans += A[i]*A[j]
        if ans >= P:
            ans = ans%P
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

wa = 0
for i in range(num - 1):
    for j in range(i + 1, num):
        a = num_line[i]%1000000007
        b = num_line[j]%1000000007
        temp = a * b % 1000000007
        wa += temp
        wa %= 1000000007
        
print(wa%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 % 1000000007
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

s = 0
# dp = [1 for _ in range(n)]
for i in range(n):
	tmp = 0
	for j in range(i+1, n):
		tmp += a[j]
	s += a[i]*tmp
		
print(s % (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
ans = 0
for i in range(N):
    for j in range(i+1, N):
        ans += A[i]*A[j]
        ans %= p
print(ans)

Submission status: Time Limit Exceeded

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

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

if sum < 1000000007:
    print(sum)
else:
    print(int(sum%(1e9 + 7)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(int(i))
    
ans = 0 
for i in range(n - 1):
    curnum = arr[i]
    for j in range(i + 1, n):
        ans += curnum * arr[j]
        if ans >= 1000000007:
            ans = ans % 1000000007

if ans >= 1000000007:
    print(ans % 1000000007)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

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]
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(i+1, N):
        sum = sum + A[i]*A[j]
        if (sum > 10**9 + 7):
            sum = sum % (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(0, N-1):
  for j in range(i+1, N):
    ans = (ans + A[i]*A[j]) % (10**9 + 7)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
D = int(1e9 + 7)
N = int(input())
M = sorted(map(int, input().split()))

sum_ = 0
for i, x in enumerate(M[:-1]):
    for j, y in enumerate(M[i+1:]):
        sum_ += ((x % D) * (y % D)) % D
        sum_ %= D

print(sum_)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

l = list(itertools.combinations(a,2))
ans = 0
for i in l:
    ans += i[0]*i[1]
print(ans%(10**9 + 7))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

ans = 0
mod = 10**9+7
for i in range(N):
    ans += (A[i]*tmp[i])%mod
    ans = ans%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 i in range(len(A)-1):
    for j in range(i+1,len(A)):
        S = (S + A[i]*A[j]%MOD)%MOD

print(S)

Submission status: Time Limit Exceeded

Solution code:
t=int(input())
arr=list(map(int,input().strip().split()))[:t]
summ=0
for i in range(0,t-1):
  for j in range(i+1,t):
    summ=summ+(arr[i]*arr[j])
print(summ%1000000007)

Submission status: Time Limit Exceeded

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

mod = 10**9 + 7
at = tuple([a[i] % mod for i in range(n)])

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

import sys
import math
from decimal import Decimal, ROUND_DOWN
from collections import deque
from itertools import combinations
import copy

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]
    a = [int(e) for e in lines[1].split(' ')]


    return (n, a)


def solve(n, a):

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


    return total
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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):
    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()))
M = 10**9 + 7
s = 0
for i in range(N):
    for j in range(N):
        if i < j:
            s += A[i] * A[j]
            s = s % M

print (s)

Submission status: Time Limit Exceeded

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

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


print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(int(i))
    
ans = 0 
for i in range(n - 1):
    curnum = arr[i]
    for j in range(i + 1, n):
        ans += curnum * arr[j]
        if ans >= 1000000007:
            ans -= 1000000007

if ans >= 1000000007:
    print(ans % 1000000007)
else:
    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,1):
    ans += A[i]*A[j]
print(ans%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
total = 0
for i in range(N):
  for k in range(N):
    if i!=k and i<k:
      total+=A[i]*A[k]
  
print(total%(10**9+7))

Submission status: Time Limit Exceeded

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

Asum = sum(As)

ans = 0
for index, A in enumerate(As):
    Asum = sum(As)
    ans += (A * (Asum - A))
    ans = ans % (10**9+7)

#    print(As)
    As = As[1:]
#    print(As)

print(ans)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()


def main():
    _ = int(input())
    hoge = tuple(map(int, input().split()))
    sumn = 0
    mod = 10 ** 9 + 7
    for pair in itertools.combinations(hoge, 2):
        sumn += (pair[0] * pair[1])
        sumn %= mod
    print(sumn)


if __name__ == '__main__':
    main()

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 += Alist[i] * Alist[j]

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

Submission status: Time Limit Exceeded

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

m = 10**9+7

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

print(ans%m)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

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

print(tot)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
count=0
num=0
for i in range(N):
  while count != N:
    count = i
    try:
      C = i+1
      num += A[i]*A[C]
      C+=1
      count+=1
    except:
      pass
print(num)

Submission status: Time Limit Exceeded

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

result = 0
MOD = 10**9+7

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

print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# from itertools import combinations
n=int(input())
a=[int(i) for i in input().split()]
pro=0
for i in range(n-1):
    for j in range(i+1,n):
        pro+=a[i]*a[j]
print(pro%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    sum_list = [0 for _ in range(n)]
    ans = 0

    for i in range(n):
        sum_list[i] = sum(a_list[i:])

    for i in range(n - 1):
        ans += a_list[i] * sum_list[i + 1] % (10 ** 9 + 7)

    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()))
MOD = 10 ** 9 + 7
ret = 0
for i in range(n-1):
  for j in range(i+1,n):
    ret += ((A[i] %MOD) * A[j]) % MOD
    ret = ret % MOD
print(ret)

Submission status: Time Limit Exceeded

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

for team in itertools.combinations(A, 2):
    ans+=(team[0]*team[1])
    if ans>=10**9+7:
        ans=ans%(10**9+7)

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