Problem:


Score : 300 points

Problem Statement

Given are N integers A_1,\ldots,A_N.

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

Constraints

2 \leq N \leq 2\times 10^5

0 \leq A_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 \ldots A_N

Output

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

Sample Input 1

3
1 2 3

Sample Output 1

11

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

Sample Input 2

4
141421356 17320508 22360679 244949

Sample Output 2

437235829



Sample input:
3
1 2 3


Sample output:
11

Submission status: Time Limit Exceeded

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

result = [a[i]*( sum(a[i+1:n]) % m ) % m for i in range(n)]
result = sum(result) % m
print(result)

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 + 1, n):
        s += a[i] * a[j]

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(n) for n in input().split()]
ans = 0
dp = []
s = 0
for a in A[::-1]:
    s += a
    dp.insert(0, s)
for i in range(0, N-1):
    ans += A[i]*dp[i+1]
print(ans%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys
import itertools

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

C = list(itertools.combinations(A,2))
# print(C[0][0])
# print(len(C))

product = 0
product_sum = 0
for i in range(len(C)):
    product = C[i][0] * C[i][1]
    product_sum = product_sum + product

answer = product_sum % (1E+9+7)
print(int(answer))

Submission status: Time Limit Exceeded

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

sum = 0
for i in range(N-1):
  for j in range(N-i-1):
    j += i+1
    p = l[i] * l[j]
    if p >= 10**9+7:
      p = p % (10**9+7)
    sum += p
print(sum % (10**9+7))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
n = 10 ** 9 + 7
A_n = [int(i) % n for i in input().split()]
A_n_mod = sum([(A_n[i] * A_n[j]) % n for i in range(N-1) for j in range(i+1, N, 1)])
res = A_n_mod % n
print(res)

Submission status: Time Limit Exceeded

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

sum = 0

j = 0
while j < n:
    i = 0
    while i < j:
        sum += a_list[i] * a_list[j]
        if sum >= 10 ** 9 + 7:
            sum = sum % (10 ** 9 + 7)
        i += 1
    j += 1

print(sum)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=[int(_) for _ in input().split()]
r=0
 
for i,ii in enumerate(A):
  for jj in A[i+1:]:
    r += (ii*jj)%(10**9+7)
 
print(r%(10**9+7))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

product = 0
for i in range(N):
    for j in range(i + 1, N):
        product = product + (L[i] * L[j])%1000000007
print(product%1000000007)

Submission status: Time Limit Exceeded

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

sum = 0

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

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

print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

a = (list(map(int, input().split())))
dx = 10 ** 9 + 7

# b = [i % dx for i in a]

ans = 0
alist = []
for i in range(n):
    for j in range(i+1, n):
        alist.append((a[i] * a[j]) % dx)

for i in range(len(alist)):
    ans += alist[i]
    ans %= dx

ans %= dx
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())  #->n=5
ai=list(map(int,input().split()))  #->nl=[1,2,-,n]

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

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

Submission status: Time Limit Exceeded

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

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

MOD = 1000000007
ans = 0

for i in range(n):
    a[i] = a[i] % MOD

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

print(ans)

Submission status: Time Limit Exceeded

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

def main(N, A_list):
    val = 0
    mod = (10 ** 9) + 7
    for i in range(len(A_list)):
        for j in range(i+1, len(A_list), 1):
            val += A_list[i] * A_list[j]

    print(val % mod)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
m = 10**9 + 7
n = int(input())
an = list(map(int, input().split()))
an_np = np.array(an)
summary = 0
for i in range(0, n-1):
    summary = (summary + sum(an_np[i] * an_np[i+1: n])) % m
print(summary)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
def main():
    number = int(input())
    num_list = list(map(int, stdin.readline().split()))
    sum = 0
    for i in range(number):
        temp = num_list[i]
        for j in range(i+1, number):
            sum += temp*num_list[j]
    div = sum // (10**9 + 7)
    print(sum - div * (10**9 + 7))
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

import sys
import itertools

def main():
    base_numbers=[]
    mod_numbers=[]
    comb=[]
    n = int(input())
    mod = 1000000007
    ans=0
    base_numbers=list(map(int,input().split()))
    for number in base_numbers:
        mod_numbers.append(number%mod)
    comb=(list(itertools.combinations(mod_numbers,2)))

    for v1,v2 in comb:
        ans+=v1*v2%mod
    print(ans%mod)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
number=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=(sum+((number[i]*number[j]%MOD)))%MOD
print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
n=int(input())
a=[int(_) for _ in input().split()]
l=list(combinations(a,2))
t=[i[0]*i[1] for i in l]    
print(sum(t)%1000000007)

Submission status: Time Limit Exceeded

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


mod=1000000007
ans=0
cnt=1

for getA in A:
    for i in range(cnt,len(A)):
        ans=(ans+getA*A[i])%mod
    cnt+=1


print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools


def main():
    count = 0
    n = int(input())
    for i in itertools.combinations(map(int, input().split()), 2):
        count += i[0]*i[1]
    return count % (10**9+7)


if __name__ == "__main__":
    print(main())

Submission status: Time Limit Exceeded

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

def add(a, b):
    return (a + b) % mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        if i != j:
            ans = add(ans,mul(a[i],a[j]))
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):
        A[i]=A[i]%mod
        A[j]=A[j]%mod
        sum+=((A[i])*(A[j] ))
print(sum%mod)

Submission status: Time Limit Exceeded

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

    ans = 0
    num = (10 ** 9) + 7

    for i in range(n):
        tmp = 0
        for j in range(i+1, n):
            tmp = (a[i] * a[j]) % num
            ans += tmp
    
    ans = int(ans % num)
    print(ans)
 
resolve()

Submission status: Time Limit Exceeded

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

mod = 10 ** 9 + 7

sum_mod = 0
for i in range(n-1):
  for j in range(i+1, n):
    res = ls_a[i] * ls_a[j]
    tmp = res % mod
    sum_mod += tmp
    if sum_mod >= mod:
      sum_mod -= mod

print(sum_mod)

Submission status: Time Limit Exceeded

Solution code:
import itertools

n = int(input())
l = tuple(map(int, input().split()))
total = []
mod = 1000000007
L = itertools.combinations(l, 2)
for a,b in L:
    num = ((a % mod) * (b % mod)) % mod
    total.append(num)
print(sum(total) % mod)

Submission status: Time Limit Exceeded

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

a.sort()

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
Sum = []
A = list(map(int, input().split()))
Sum = [np.array(A[i])*np.array(A[j]) for j in range(N) for i in range(j)]
print(np.array(Sum).sum()%(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-1):
    for j in range(i+1,n):
        s = a[i] * a[j]
        ans = ans + s

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

Submission status: Time Limit Exceeded

Solution code:
import itertools

n = int(input())
a = list(map(int, input().split()))
s = 0
for (i, j) in list(itertools.combinations(range(n), 2)):
    s += a[i] * a[j]
print(s % 1000000007)

Submission status: Time Limit Exceeded

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


def amari(num):
    return num % (10**9+7)


# print(amari(5))
# print(a)
a = list(map(amari, a))
# print(a[0])
sum = 0
for i in range(n):
    for j in range(i+1, n):
        sum += a[i]*a[j]
print(sum % (10**9+7))

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

N = int(input())
A_list = tuple(map(int, input().split(' ')))

# print(N)
# print(A_list)

ret = 0
# 重複なしの組み合わせごとに積を出し、その和
for comb in combinations(A_list, 2):
  # print(comb)
  ret += comb[0] * comb[1]
  
print(ret % 1000000007)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
result = 0
i = 0
for x in A[:N]:
  for y in A[i+1:]:
    result += x * y
  i += 1

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

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)): 
    while(j<=len(l)): 

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())
a = list(map(int, input().split()))
len_a = len(a)
range_a = range(len_a)
times1 = []
times2 = []

for i in range_a:
    times1 += [a[i]] * (len_a - (i + 1))
    times2 += a[i + 1 : ]

result = np.array(times1, dtype = "uint64") * np.array(times2, dtype = "uint64")

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
MOD = 1000000007
sum = 0

a = list(map(int,input().split()))
for i in range(0,N-1):
	for j in range(i+1,N):
		sum = sum + a[i]*a[j]
		


print(sum % MOD)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

MOD = 1000000007

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

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

Submission status: Time Limit Exceeded

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

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

MOD = 1000000007
ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def modsum(l, p):
    ret = 0
    for x in l:
        ret += x
        ret %= p
    return ret

N = int(input())
p = 10**9+7
A = [int(a) for a in input().split()]
ans = 0
for i in range(N):
        ans += A[i]*modsum(A[i+1:], p)
        ans %= p
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools


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

MOD = 1000000007

l = []
for i in range(N):
    l.append(i)

C = itertools.combinations(l, 2)

a = 0
for c in C:
    a += A[c[0]] % MOD * A[c[1]] % MOD
a %= MOD
print(a)

Submission status: Time Limit Exceeded

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

n = int(input())
nums = list(map(int, input().split()))
x = 10 ** 9 + 7

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    from sys import stdin
    readline = stdin.readline
 
    N = int(readline().rstrip())
    A = [ int(x) for x in readline().rstrip().split()]
 
    total =  0
 
    for i in range(N):
        An = int(A.pop())
        for j in A:
            Am = int(j)
            total += (An * Am)
 
    print(total % (10**9 + 7))
 
main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
s = int(input())

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

ans = 0
for i in range(s-1):
    for j in range(s - i -1):
        ans =  ans + (num[0] * num[j+1])
    del num[0]

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
n=int(input())
a=[int(_) for _ in input().split()]
l=list(combinations(a,2))
t=[]
for i in l:
    t.append(i[0]*i[1])
    
print(sum(t)%1000000007)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
num = input().split()

ass = 0

for i in range(k):
    for j in range(i+1,k):
        n1 = int(num[i]) % (10**9 + 7)
        n2 = int(num[j]) % (10**9 + 7)
        n3 = n1 * n2
        ass += n3
        ass = ass % (10**9 + 7)
    ass = ass % (10**9 + 7)


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

Submission status: Time Limit Exceeded

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


def findProductSum(A, n):

    product = 0
    for i in range(n):
        for j in range(i+1, n):
            product = product + A[i]*A[j]
    return product%(10**9 + 7)
print(findProductSum(A,N))

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
p = list(map(int,input().split()))
mod = 10**9 + 7
t = 1
sum_list = []
for i in range(a):
    for t in range(a):
        if i >= t:
            continue
        w = p[i]*p[t]
        sum_list.append(w)

print(sum(sum_list)%mod)

Submission status: Time Limit Exceeded

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

for i,ii in enumerate(A):
  for jj in A[i+1:]:
    r += (ii*jj)%(10**9+7)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def main(N, A_list):
    val = 0
    mod = (10 ** 9) + 7
    for i in range(len(A_list)):
        for j in range(i+1, len(A_list), 1):
            val = (val + (A_list[i] * A_list[j])) % mod
    
    print(val)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)

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):
        hoge = a[i]*a[i+1+j]
        while hoge >= 1000000007:
            hoge = hoge - 1000000007
        ans = ans + hoge
        if ans >= 1000000007:
            ans = ans - 1000000007
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int, input().split()))
ans=0
cnt=0
# while True: """
for i in range(n-1):
    for j in range(i+1, n):
        ans+= (a[i]*a[j])%1000000007
print(ans%1000000007)

Submission status: Time Limit Exceeded

Solution code:
from sys import setrecursionlimit
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
from time import time
import re
setrecursionlimit(10**9)
mod=10**9+7
inf=10**18

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=a
k=0
j=0
while len(b)!=1:
    j=b[0]
    b.pop(0)
    k+=j*sum(b)
print(k%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nl = list(map(int, input().split()))
val = 0

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

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

Submission status: Time Limit Exceeded

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

threshold = 1000000007
ans = 0
for i in range(N-1):
    count = 0
    for j in range(i+1, N):
        count += list_A[j]
    count = count % threshold
    ans += (list_A[i] * count % threshold)
ans = ans % threshold
print(ans)

Submission status: Time Limit Exceeded

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

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

print(s)

Submission status: Time Limit Exceeded

Solution code:
N=input()
A=list(map(int,input().split()))
mod=10**9+7
kot=0
mozilen=len(A)

for a in range(len(A)-1):
    gou=0
    gou+=(sum(A[a+1:mozilen]))%mod

    gou*=A[a]
    gou=gou%mod
    kot+=gou
    kot=kot%mod
print(kot)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

n=int(input())  #->n=5
ai=list(map(int,input().split()))  #->nl=[1,2,-,n]

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

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

Submission status: Time Limit Exceeded

Solution code:
import itertools

n = int(input())
l = tuple(map(int, input().split()))
total = 0
mod = 1000000007
L = itertools.combinations(l, 2)
for a,b in L:
    total += ((a % mod) * (b % mod)) % mod
print(total % mod)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
from collections import Counter

N = int(input())
lst = list(map(int,input().split()))
newlst = list(combinations(lst,2))

sumlst = []
for a, b in newlst:
    x = a * b
    sumlst.append(x)

modlst = sum(sumlst)
answer = modlst % (10**9 + 7)

print(answer)

Submission status: Time Limit Exceeded

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


mod=1000000007
ans=0
cnt=1

def getMod(factor1,factor2):
    global ans
    ans=(ans+factor1*factor2)%mod
    return ans


for getA in A:
    for i in range(cnt,len(A)):
        getMod(getA,A[i])
    cnt+=1


print(ans)

Submission status: Time Limit Exceeded

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

k = 1000000007

ans = 0
for s in range(len(A)-1):
    ans += A[s]*sum(A[s+1:])

print(ans%k)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# abc177-c
import itertools
n = int(input())
list = list(map(int, input().split()))
cumsum = 0
for pair in itertools.combinations(list, 2):
    cumsum += (pair[0] * pair[1])
print(cumsum % (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):
    a2=0
    for j in range(i+1,n):
        a2 = (a2+a[j]) % (10**9+7)
    ans = ( ans + (a[i]*a2) )%(10**9+7)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

total = 0
mod = 1000000007

for i in range(0,n-1):
    for x in range(i+1,n):
        seki = (list1[i] % mod) * (list1[x] % mod)
        seki = seki % mod
        total += seki



kotae = total % mod

print(kotae)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
z = list(map(int,input().split()))
_sum = 0
y = len(z)
for i in range(y-1):
    a = z[i]
    b = sum(z[i+1:y])
    
    #print("b:"+str(b))
    _sum += (a*b)
        #print("_sum:"+str(_sum))
print(_sum % (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(N - 1):
    for j in range(i + 1, N):
        sum += A[i] * A[j]


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

print(sum)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
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:]) % mod)) % mod
    ans = ans % mod
print(ans)

Submission status: Time Limit Exceeded

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


ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# vim: fileencoding=utf-8


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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
s=0
for i in range(n-1):
    #一つ目選ぶ
    s+=a[i]*sum(a[i+1:n])
print(s%1000000007)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

total = 0
for i in range(n - 1):
  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()))
    
b=[]
for i in range(n-1):
    for j in range(i+1,n):
        b.append(a[i]*a[j])
print(sum(b)%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
import itertools


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

MOD = 1000000007

l = []
for i in range(N):
    l.append(i)

C = itertools.combinations(l, 2)

a = 0
for c in C:
    a += (A[c[0]] * A[c[1]]) % MOD
a %= MOD
print(a)

Submission status: Time Limit Exceeded

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

total = 0

for i in range(n-1):
    j = i+1
    while j < n:
        total += a[i]*a[j]
        j+=1

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

Submission status: Time Limit Exceeded

Solution code:


N = int(input())
As = list(map(int,input().split()))
MOD = 1000000007
sum = 0
for i,a in enumerate(As):
	for a2 in As[i + 1::]:
		sum = (sum + a * a2 % MOD) % MOD

print(int(sum))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(N-1):
    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 = [0] * N
A = list(map(int,input().split()))

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = [int(i) for i in input().split()]
ans = 0
mod = 10**9+7
amari = [i%mod for i in A]
for i in range(len(A)-1):
    for j in range(i+1,len(A)):
        ans += (amari[i] * amari[j])%mod
if ans < mod:
    print(ans)
else:
    print(ans%mod)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
MOD = 1000000007

n = int(input())
str_ary = input().split()
ary = [int(c) for c in str_ary]

result = 0
# for diff in range(n - 1):
#   for i in range(n - diff - 1):
#     # print(i, i + diff + 1)
#     sum += ary[i] * ary[i + diff + 1]
for i in range(n):
  sum = 0
  for j in range(n - i - 1):
    # print(i, j + i + 1)
    sum += ary[j + i + 1]
  result += ary[i] * sum

print(result % MOD)

Submission status: Time Limit Exceeded

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