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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

MOD = 10**9 + 7

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

print(result)

Submission status: Time Limit Exceeded

Solution code:
import numba
from numba import njit, b1, i4, i8, f8
import numpy as np  # noqa

N = int(input())
A = np.array([int(x) for x in input().split()], dtype=np.int32)


@njit((i4[:], ), cache=True)
def main(A):
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            ans = (ans + A[i] * A[j]) % (10**9 + 7)
    return ans


print(main(A))

Submission status: Time Limit Exceeded

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

n = int(input())
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] * a[j]
print(ans % mod)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

c = 0

for i in range(N-1):
  for j in range(int(i)+1, N):
    d = A[i] % (10**9+7)
    e = A[j] % (10**9+7)
    f = (d*e) % (10**9+7)
    c += f
    

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

print(c)

Submission status: Time Limit Exceeded

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

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]
        s %= 1000000007
print(s % 1000000007)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

# from typing import Optional
# from typing import List
# from typing import Dict
# from typing import Tuple
# from typing import Sequence


def main():
    N = int(input())
    A = list(map(lambda x: int(x), input().split()))

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

    print(sum)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

biggest = 0
humidai = 0

result = 0


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

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

print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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):
    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("")) - 1
a = input("").split(" ")
a = [int(b)%(10**9+7) for b in a]
i = 0
j = 0
ans = 0
while i < n:
  j = i + 1
  while j <= n:
    ans += a[i]*a[j]
    j += 1
  i += 1
print(ans%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
n = input()
sz = input().split(" ")
t = []
for i in range(len(sz)) :
    t.append(int(sz[i]))

ans = 0
mod = 1e9 + 7

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

print(int(ans%mod))

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
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:
#!/usr/bin/env python
# coding: utf-8

# In[13]:


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


# In[14]:


mod = 10**9+7
a_sum = sum(A)
mylist = [(a_sum-sum(A[:i+1]))*a for i,a in enumerate(A)]
ans = sum(mylist)%mod
print(ans)


# In[ ]:

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
nums = list(map(lambda x: int(x), input().split()))

ans = 0
for i in range(num-1, 0, -1):
  ans += nums[i] * sum(nums[:i])
  
print(ans%(10**9+7))

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] * a[other]
print(sum % (10**9 + 7))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
*A,=map(int,input().split())
t=10**9+7
S=[a%t for a in A]

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

Submission status: Time Limit Exceeded

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

for v in itertools.combinations(a, 2):
    ans += v[0]*v[1]
    if 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()))

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

Submission status: Time Limit Exceeded

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

    print(sum)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans=0
inf=10**9+7
flag=True
for i in range(N-1):
    if A[i]!=0:
        for j in range(i+1,N):
            temp=(A[i]*A[j])%inf
            ans+=temp
            ans%=inf
 
          
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
t = 0
L = []
for e in a:
    L.append(e%(10**9+7))


for i in range(len(a)):
    for j in range(i, len(a)):
        if i != j:
          t += L[i]*L[j]

print(t%(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):
    for j in range(i):
        sum+=a[i]*a[j]

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

print(ans)

Submission status: Time Limit Exceeded

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ret = 0
    sum_list = [None] * n + [0]
    for i in range(n):
        sum_list[i] = sum(a[i:])
    for i in range(n):
        ret += a[i] * sum_list[i+1]
        ret %= 1000000007
    print(ret)

if __name__ == "__main__":
    main()

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 = [int(_)%(10**9+7) for _ in input().split()]

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

Submission status: Time Limit Exceeded

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    A = LIST()

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

    print(ans % mod)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#Written by Shagoto

n = int(input())
l = list(map(int, input().split(" ")))
ans = 0
for x in range(0, n-1):
    for i in range(x+1, n):
        temp = (l[x] * l[i])
        ans += temp

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):
    for j in range(i+1,n):
        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()))
ans = 0
for i in range(0,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:
from itertools import combinations

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

mod = 10**9+7
c = combinations(A, 2)
ans = 0

for v in c:
    ans += v[0] * v[1]
print(ans%mod)

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]

print(ans % 1000000007)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0

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

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

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

kumiawase = list(itertools.combinations(a, 2))
ans = 0

for i in range(len(kumiawase)):
  ans += kumiawase[i][0] * kumiawase[i][1]
  
print(ans % (1000000000+7))

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

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

mod = (10**9)+7

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

print(out)

Submission status: Time Limit Exceeded

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

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):
        b = b + a + 1
        s = s + A[a] * A[b]
print(s % (10**9 + 7))

Submission status: Time Limit Exceeded

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

result = 0
for i in range(len(a)):
    for j in range(i):
        result += a[i] * a[j] % 1000000007

print(result % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(set(b))  重複を削除
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]
##v = [s[i: i+2] for i in range(0, len(s), 2)]
##  s="12345678" を v=["12","34","56","78"] にするイメージ
##s = "".join(list)リストを文字列に変換[""]は区切り文字
##a.sort(key=itemgetter(1))リストをソートできるよ(from operator import itemgetterが必要)
##sort_p = sorted(p) 昇順ソート

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
import copy
import time
# stdin = open("sample.txt")


MOD = int(1e9+7)
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr
    
def main():
    N = int(stdin.readline().rstrip())
    A = list(map(int,[int(x) for x in stdin.readline().rstrip().split()]))
    ans = 0
    for i in range(N-1):
        for j in range(i+1,N):
            ans += (A[i]*A[j]) % MOD
    print(ans%MOD)
main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
mod=10**9+7
def do():
    n=INT()
    A=LIST()
    B=[0]*(n)
    ans=0
    for i in range(1,n):
        B[i]=sum(A[i:])%mod

    for i in range(n-1):
        ans+=(A[i]*B[i+1])%mod
        ans=ans%mod

    print(ans)

    

    
if __name__=='__main__':
    do()

Submission status: Time Limit Exceeded

Solution code:
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import itertools

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    mod=10**9+7
    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    ans=0
    for p in itertools.combinations(arr,2):
        ans=(ans+p[0]*p[1])%mod
    #ss=readline().rstrip()
    #yn(1)
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Submission status: Time Limit Exceeded

Solution code:
def s():return int(input())
def mp():return map(int,input().split())
# a =s()
# b =s()
# ans = ""
# for i in range(len(b)):
# 	ans+=b[i]
# 	if ans in a:
# 		pass
# 	else:
# 		print(len(b)-i)
# 		break

a = s()
b = list(mp())
ans=0
for i in range(a):
	for j in range(i+1,a):
		ans+=b[i]*b[j]
		ans%=((10**9)+7)
print(ans)

Submission status: Time Limit Exceeded

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

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

A_sum = sum(A)
ans = 0

for i in range(N-1):
    B = A.pop(0)
    A_sum -= B
    ans += A_sum*B
print(ans % (10**9+7))

Submission status: Time Limit Exceeded

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

sum = 0
mod = 10**9+7

for i in range(N):
    for j in range(i+1,N):
        if i>=j:
            continue
        else:
            sum += A[i]*A[j]
        if sum > mod:
            sum = sum%mod

ans = sum
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(n):
    for j in range(n):
        if i != j:
            ans += A[i] * A[j]

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
MOD = 1000000007
n=int(input())
a=list(map(int,input().split()))
sum=0
for x,y in combinations(a,2):
   sum+= x*y
print(sum%MOD)

Submission status: Time Limit Exceeded

Solution code:
import sys
from itertools import combinations


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
A = inintl()

MOD = 1000000007

ans = 0

for c in combinations(A,2):
    ans += c[0]*c[1] % MOD

print(ans % MOD)

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

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)

print(tot)

Submission status: Time Limit Exceeded

Solution code:
import sys

input_ = sys.stdin.readline

N = int(input_().strip())
A = [int(x) for x in input_().strip().split(" ")]
M = 1000000007

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

print(sum([(ai * aj) % mod for ai, aj in itertools.combinations(A, 2)]) % mod)

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    mod = 10**9+7
    count = 0

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
a_list = list(map(int, input().split()))

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

Submission status: Time Limit Exceeded

Solution code:
# C

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

Asum=[sum(A[i+1:])%p for i in range(len(A))]
print(sum((A[i]*Asum[i])%p for i in range(N))%p)

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 list(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().rstrip()) #個数
line = input().rstrip().split(" ") #Ai
isum = 0

for i in range(N - 1):
    for j in range((i + 1), N):
        isum += int(line[i]) * int(line[j])

print(isum % (1000000007))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

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

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

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

Submission status: Time Limit Exceeded

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

sum = 0

for i in range(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:
import sys

n = int(sys.stdin.readline())
lst = list(map(int, sys.stdin.readline().split()))
ans = 0
for i in range(len(lst)):
    ans += lst[i] * sum(lst[i+1:])

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a  = [int(i) for i in 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]) % mod
        ans %= mod

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N=int(input())
A=np.array(input().split(" "),dtype=np.int64)

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

c = 0

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

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

print(c)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = [int(i) for i in input().split()]
import math
ans = 0
for i in range(len(A)-1):
    ans += A[i]*sum(A[i+1:len(A)])
j = 10**9+7
print(ans%j)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(ans%N)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**6)

MOD = 10**9+7


def main(input, print):
    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 %= MOD
    print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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] % m) * (a[j] % m) % m
       ans %= m
print(ans)