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:
def resolve():
    import sys
    input = sys.stdin.readline

    n = input().rstrip()
    a_list = [int(x) for x in input().rstrip().split(" ")]

    import itertools

    c = itertools.combinations(a_list, 2)

    x = 1000000007

    ans = sum([v[0] * v[1] for v in c]) % x

    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    AArray = LI()
    MOD = 1000000007

    ans = 0

    for i in range(N-1):
        a = AArray[i]
        asum = sum(AArray[i+1:])
        asum %= MOD
        ans += a*asum % MOD
    ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

sum = 0

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
""" C
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

def main(N, A):
    M = pow(10, 9) + 7
    result = 0
    for i in range(len(A)):
        result = (result + A[i] * sum(A[i+1:len(A)])) % M
    return result

if __name__ == "__main__":
    _N = readInteger()
    _A = readIntegerSet(_N)

    print(main(_N, _A))

Submission status: Time Limit Exceeded

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

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]

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

print(_sum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A_l = [int(i) for i in input().split()]
a_sum = 0
for i in range(N):
    if A_l[i] == 0: continue
    for j in range(i+1,N):
        if A_l[j] == 0: continue
        a_sum = a_sum + (A_l[i] * A_l[j])
print(a_sum % (10**9+7))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

mod_number = 10**9 + 7

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

ans = total % mod_number

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

p = list(itertools.combinations(range(n), 2))

ans = 0
for i in p:
    ans += a[i[0]] * a[i[1]]

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

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

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

Submission status: Time Limit Exceeded

Solution code:
ans = 0
N = int(input())
array = list(map(int, input().split()))
for i in range(N):
  for j in range(N):
    if i != j and i < j:
      ans += array[i]*array[j]
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()))

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

print(ans%mod)

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())
numbers = [int(i) for i in input().split(" ")]
newNumbers = map(lambda x : x % (10**9+7), numbers)

sum = 0
for number in itertools.combinations(newNumbers,2):
    sum = sum + (number[0] * number[1]) % (10**9+7)

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

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

Submission status: Time Limit Exceeded

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

ans = 0
for a in AA:
  ans += a
ans = ans % (10**9+7)
ans = ans**2
for a in AA:
  ans -= a**2
  while ans<0:
    ans += 10**9+7
  ans = (ans) % (10**9+7)
ans = ans % (10**9+7)
print(int(ans/2))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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 += 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()))
x = 0
for i in range(0,n-1):
    y = 0
    for j in range(i+1, n):
        y = y + a[j]

    x = (x + (a[i]*y) % (10**9+7)) % (10**9+7)

print(x)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

sum = 0

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

mod = lambda x: x % 1000000007
s = 0

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

print(s)

Submission status: Time Limit Exceeded

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

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

MOD = 1000000007
print(sum%MOD)

Submission status: Time Limit Exceeded

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

s = [0]*n

for i in range(n):
    s[i] = sum(A[i+1:])


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

Submission status: Time Limit Exceeded

Solution code:
from typing import List
import sys


def solution(inp: List) -> int:
    inp = list(map(int, inp))
    ans: int = 0
    inp.pop(0)
    l = len(inp)
    for i in range(l-1):
        for j in range(i+1, l):
            ans += inp[i] * inp[j]
    q, mod = divmod(ans, 1000000007)
    return mod


inp: List = []
for j in sys.stdin:
    inp += j.split()
print(solution(inp))

Submission status: Time Limit Exceeded

Solution code:
import itertools
n = int(input())
a = list(map(int, input().split()))
total = 0
for x in list(itertools.combinations(a, 2)):
    total += (x[0]*x[1])
    total %=  1000000007
print(total)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化
INF = 10**9 + 7

def main():
    n = int(input())
    N = list(map(int,input().split()))
    ans = 0
    for i in range(n - 1):
        #print(N[i] , sum(N[i + 1:]))
        ans_temp = (N[i] * sum(N[i + 1:])) % INF
        ans += ans_temp
        ans = ans % INF
    print(ans)

    return 0

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

com_A = [x * y for x,y in combinations(A,2)]
print(sum(com_A) % (10**9 + 7))

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

Submission status: Time Limit Exceeded

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

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


print(s%m)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


MOD = 10 ** 9 + 7


def main():
    N = II()
    target = LI()

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


main()

Submission status: Time Limit Exceeded

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

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# abc177_c.py
# https://atcoder.jp/contests/abc177_c


# [開発時用] ログ関数
def lg(value):
    flag = False
    # flag = True
    if flag:
        print(str(value))


# [開発時用] exit処理
def xt(log):
    lg('★exit() - ' + str(log))
    exit()


# 本体
def get_results():

    # 引数処理部
    lines = list()
    # 仕様でn行と決まっている場合(の例)
    lines_count = 2
    # 先頭行のNで行数が決まる場合(の例)
    # line = input()
    # lines.append(line)
    # N = int(line)
    # lines_count = N
    for _ in range(lines_count):
        lines.append(input())

    # 演算部
    # S = lines[0]
    N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    lg(f'values=[{values}]')

    su = 0
    for i in range(N-1):
        for j in range(i+1, N):
            lg(i * 100 + j)
            su = (su + values[i] * values[j]) % (10**9+7)

    return [su]


# 主処理
def main():
    results = get_results()

    for result in results:
        print(result)


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
n = int(input())
summ = 0
#n , m, p = map(int, input().split())
lst = list(map(int, input().split()))
data = list(combinations(lst, 2))
for i in data:
    k = i[0] * i[1]
    summ += k
print(summ % ((10 ** 9) + 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):
            seki = a[i] * a[j]
            ans += seki % m
            if ans >= m:
                ans = ans % m
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
from itertools import combinations

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split(" ")))

    res = 0
    for i, j in combinations(A, 2):
        res += (i * j)
    print(res % (10 ** 9 + 7))
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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:
            sum = sum%1000000007


print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    A  = [int(i) for i in input().split()]
    #ax = itertools.combinations(A, 2)
    ans = 0
    for i in range(N):
        for j in range(i+1,N):
            ans = (ans + A[i]*A[j]) % 1000000007
            #print(A[i],A[j],ans)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
import itertools

def resolve(in_):
    N = int(next(in_))
    A = list(map(int, next(in_).split()))

    mod = 10 ** 9 + 7
    ans = 0
    for i, a in enumerate(A):
        v = sum(A[i + 1:])
        ans += a * v
        ans %= mod

    return ans
    

def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


def main():
    import itertools

    N, *A = map(int, open(0).read().split())
    print(sum([A[i] * v2 for i in range(N) for v2 in A[i + 1 :]]) % (10 ** 9 + 7))


main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(ans % mod)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

mod = 10**9+7

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

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

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

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

Submission status: Time Limit Exceeded

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

ans = 0

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

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

Submission status: Time Limit Exceeded

Solution code:

def findProductSum(A,n): 

	product = 0
	for i in range (n): 
		for j in range ( i+1,n): 
			product = (product%1000000007 + A[i]*A[j]%1000000007 )%1000000007
	return product 


if __name__=="__main__": 

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

	print(
	findProductSum(A, n))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
mod = 1000000007

l = list(input().split())
for i in range(n):
  l[i] = int(l[i])

total = 0
for i in range(n):
  for j in range(i+1, n):
    total += (l[i] * l[j]) % mod

print(total % mod)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
mod = 1000000007
i3 = 0
N = int(input())
alist = list(map(int, input().split()))
for i in itertools.combinations(alist, r=2):
    i2 = i[0]*i[1]%mod
    i3 = i3 + i2
    if i3 > mod:
        i3 = i3%mod
print(i3)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# import math


def get_int_args():
    args = input().split()
    return list(map(int, args)), len(args)


def get_str_args():
    return input().split()


if __name__ == '__main__':
    n = int(input())
    a = get_int_args()[0]
    sum = 0;
    for i in range(len(a) - 1):
        for j in range(i + 1, len(a)):
            sum += a[i] * a[j]
            sum %= int(1e9 + 7)
    print(sum)

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

print(sums)

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):
        if (i<j):
            sum=(sum+(l[i]*l[j]))%x
print(sum)

Submission status: Time Limit Exceeded

Solution code:
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 h in range(len(hoge)):
        if h+1 <= len(hoge):
            for hh in range(h+1, len(hoge)):
                sumn += hoge[h] * hoge[hh]
                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
_mod = 1000000007
for i in range(N-1):
    for j in range(i+1, N):
        _sum += (Alist[i] * Alist[j])%_mod

print( _sum % _mod )

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    input()  # n
    array = [int(x) for x in input().split()]
    mod = 10 ** 9 + 7
    ans = 0
    for i, ai in enumerate(array):
        for aj in array[i + 1:]:
            ans += ai * aj
            ans %= mod
    return ans


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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
ans=0
for i in range(len(A)-1):
    for j in range(i+1,len(A)):
        ans+=A[i]*A[j]
        
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(len(a)):
    ans += a[i] * sum(a[i+1:])
print(ans % m)

Submission status: Time Limit Exceeded

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

ans = 0

m = 10**9+7

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(int(y) for y in input().split())
b=[]
c=[]
for i in range(n):
    b.append(a[i]%((10**9)+7))

for i in range(n):
    for j in range(i+1,n):
        # print(a[i]*a[j]%((10**9)+7))
        c.append((b[i]*b[j])%((10**9)+7))
print(sum(c)%((10**9)+7))

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):
#            tmp = (a[i] * a[j]) % m
#            total = (total + tmp) % m
        total = (total + (a[i] * (sum(a[i+1:n]) % m)) % m) % 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())
As = list(map(lambda x: int(x), input().split(" ")))

result = 0
MOD = 10**9+7

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

print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    import sys
    input = sys.stdin.readline

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

    ans = 0
    for i in range(N):
        ans += sum(list(map(lambda x: A[i] * x, A[i + 1:])))
    print(ans % (10 ** 9 + 7))


main()

Submission status: Time Limit Exceeded

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

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]

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
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]
        if s > 10 ** 9 + 7:
            s = s % (10 ** 9 + 7)
print(s)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

for i in itertools.combinations(num_list, 2):
    sum += (i[0] * i[1]) % (10**9 + 7)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

from itertools import combinations

num = 10**9 + 7
ans = 0
for ai, aj in combinations(A, 2):
    ans += ai*aj
    ans %= num
    
print(ans)

Submission status: Time Limit Exceeded

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

import itertools

sum = 0
for i, j in itertools.combinations(A, 2):
    sum += i * j

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    mod = 10 ** 9 + 7
    ans = 0
    for i in range(n):
        ans += (np.sum(A[i + 1:]) * A[i]) % mod
        ans %= mod
    print(int(ans))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

mod = (10**9) +7

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

print(ans%mod)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A_list = list(map(int, input().split()))
myans_list =  [ [0 for n in range(N)] for nn in range(N) ]
myans = 0
for n in range(N):
    for nn in range(N):
        myans_list[n][nn] = A_list[n] * A_list[nn]
#for n in myans_list:
#    print(n)
myans = 0
for n in range(N-1):
    for nn in range(n+1, N):
        myans += myans_list[n][nn]
print(myans%(1000000007))