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:
from itertools import combinations

def main():
  N = int(input())
  As = list(map(int, input().split()))
  w = [(i[0] * i[1]) for i in combinations(As,2)]
  print(sum(w) % 1000000007)

main()

Submission status: Time Limit Exceeded

Solution code:

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

Submission status: Time Limit Exceeded

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

M=1000*1000*1000+7

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

print("{}".format(SS%M))

Submission status: Time Limit Exceeded

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

su = pow(sum(arr),2,1000000007)
other = sum([(arr[i]%1000000007*(sum(arr[:i+1])%1000000007))%1000000007 for i in range(n)])
print((su-other)%1000000007)

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 = [(A_n[i] * A_n[j]) % n for i in range(N-1) for j in range(i+1, N, 1)]
res = sum(A_n_mod) % n
print(res)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod_v = 10**9 + 7
    ans = 0
    for i in range(0, N):
        for j in range(i + 1, N):
            if i != j:
                ai = A[i]
                aj = A[j]
                ans += ai * aj
                if ans > mod_v:
                    ans = ans % mod_v
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin


def mod(val):
    res = val % (10 ** 9 + 7)
    if (res < 0):
        res += (10 ** 9 + 7)
    return res


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    A_arr = list(map(int, _in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    A_arr_mod = [0] * len(A_arr)
    for i, a in enumerate(A_arr):
        A_arr_mod[i] = mod(a)

    ans = 0
    for i in range(N-1):
        ans += A_arr_mod[i] * sum(A_arr_mod[i+1:])
    ans = mod(ans)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A = list(map(int, input().split()))
all=0
for index,i in enumerate(A):
    for k in range(len(A)-index-1):
        all+=i*A[k+index+1]
if all>10**9+7:
    q, mod = divmod(all, 10**9+7)
    print(mod)
else:
    print(all)

Submission status: Time Limit Exceeded

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

print(ans%mod)

Submission status: Time Limit Exceeded

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

mod = 1000000000 + 7
ans = 0

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

ans %= mod
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# abc177_c.py
N = int(input())
A = list(map(int,input().split()))
ans = 0
mod = 10**9+7
for i in range(N):
    for j in range(i,N):
        if i != j:
            ans+=A[i]*A[j]
            ans%=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(len(A)):
    A[i] %= (10**9 +7)
for i in range(n):
    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:
from itertools import combinations

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

comb = list(combinations(range(N), 2))
sum = 0
mod = 10**9 + 7
for i in range(len(comb)):
        sum += A[comb[i][0]] * A[comb[i][1]] % mod
print(sum % mod)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

num = int(input())
total = 0
str = input().split(" ")
table2 = list(str)
for i in range(num-1):
    for j in range(i+1, num):
            total += int(table2[i]) * int(table2[j])
print(total % 1000000007)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

    sum_a = 0

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

  #  print(sum_a)

    ans = sum_a % 1000000007

    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A= list(map(int,input().split()))
mod_num = 1.0e+9 + 7
for i in range(len(A)):
  A[i]= A[i]%mod_num
rest = 0
for i in range(N-1):
  for j in range(N-i-1):
    rest +=A[i]*A[i+j+1]
    

    
print(int(rest%mod_num))

Submission status: Time Limit Exceeded

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


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

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

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[int(i)for i in input().split()]
res=0
for i in range(n-1):
    res+=sum(map(lambda x:x*a[i]%(1000000000+7),a[i+1:]))

print(res%(1000000000+7))

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

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

result = 0
for itr in itertools.combinations(A,2):
    result = (result + (itr[0]*itr[1])%M)%M

print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def multmod(a,b,m):
  ans = 0
  a = a % m
  
  while b:
    if (b & 1): # odd
      ans = (ans + a) % m
    
    a = (2 * a) % m
    b >>= 1 # b = b / 2
    
  return ans


n = int(input())
S = [int(a) for a in input().split()]
divisor = 10**9 + 7
tot = 0
a,b = 0,0
for i in range(n-1):
  b = 0
  for j in range(i+1,n):
    b += S[j]
    b = b % divisor
  a = S[i]
  tot += multmod(a,b,divisor)
  if tot >= divisor:
    tot = tot % divisor
    
print(tot)

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

Submission status: Time Limit Exceeded

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

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


print(count%MOD)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    numbers = int(input())
    number_list = list(map(int, input().split()))
    answer = 0
    for i in range(numbers - 1):
        num1 = number_list[i]
        num2 = sum(number_list[i+1:])
        answer += num1*num2
    print(answer%1000000007)
resolve()

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):
    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()))
MOD = 10**9+7

ans = 0
for i in range(n):
    plus = 0
    for j in range(i, n):
        if i == j:
            continue
        plus += a[j]%MOD
    ans += a[i]*plus 
    ans %= MOD
print(ans)

Submission status: Time Limit Exceeded

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

def m(i):
  return i%(10**9+7)

for i in range(N):
  for j in range(i+1,N):
    r += m(A[i]*A[j])
    #print(A[i],A[j],r)

print(m(r))

Submission status: Time Limit Exceeded

Solution code:
N,*A=map(int,open(0).read().split())
m=1000000000+7
ans=0
for i in range(N):
    for j in range(i+1,N):
        ans+=(A[i]*A[j])
        ans%=m
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

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

ans = 0
for i, j in C:
    ans += i * j
    ans = ans % (1e9 + 7)
print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
import itertools

if __name__ == '__main__':

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

	total = 0
	C = list(itertools.combinations(A, 2))
	B = [v[0]*v[1] for v in C]
	print(sum(B)%(10**9+7))

Submission status: Time Limit Exceeded

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

A = list(map(lambda x: x%1000000007,A))

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

Submission status: Time Limit Exceeded

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

import itertools

total = 0

for pair in itertools.combinations(A, 2):
  total += pair[0]%(10**9 + 7) * pair[1]%(10**9 + 7)

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
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:
s = int(input())

num = input()
num = num.split()
 
for i in range(s):
    num[i] = int(num[i])

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

A_list = [int(_) for _ in input().split()]

ans = 0
for i in range(len(A_list)):
    if i <= N-1:
        if A_list[i] == 0:
            continue
        j = i+1
        ans += sum(map(lambda x:x*A_list[i], A_list[j:N]))%(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().strip().split()))
ans = 0
mod = 1000000007
for i in range(0,n-1):
    #temp = 0
    for j in range(i + 1, n):
        ans += a[i]*a[j]
        #temp += a[j]
    #ans += (((a[i] % mod) * (temp % mod)) % mod) % mod
print(ans % mod)

Submission status: Time Limit Exceeded

Solution code:
l = int(input())
ll = list(map(int,input().split()))
sum = 0

for i in range(len(ll)):
  for ii in range(len(ll)):
    if i >= ii:
      continue
    s = ll[i]*ll[ii]
    sum += s
  
mod = pow(10,9)+7
print(sum % 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]

ans = ans % 1000000007
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

mod = 1000000000 + 7
ans = 0

for i in range(n):
    for j in range(n):
        pdt = 0
        if i<j:
            pdt = a[i] * a[j]
        ans %= mod
        ans += pdt

ans %= mod
print(ans)

Submission status: Time Limit Exceeded

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

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

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

for i in range(N):
  x = sum(A[i+1:]) % MOD
  y = (A[i] * x) % MOD
  ans += y
  ans %= MOD

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
n = int(input())
l = list(map(int, input().split()))
total = 0
mod = 1000000007
ans = 0
for a,b in itertools.combinations(l, 2):
    total += ((a % mod) * (b % mod)) % mod
print(total % mod)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,*A=map(int,open(0).read().split())
m=1000000000+7
ans=0
for i in range(N):
    for j in range(i+1,N):
        ans+=A[i]*A[j]
ans%=m
print(ans)

Submission status: Time Limit Exceeded

Solution code:
ans = 0
mod = 1e9+7

N = int(input())
A = [int(num)%mod for num in input().split()]

for i in range(N-1):

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

ans = int(ans%mod)
print(ans)

Submission status: Time Limit Exceeded

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

print(sum(test) % INF)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(ans % mod)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
"""ans = 0
fac = []
finv = []
inv = []
def init():
    fac.append(1)
    fac.append(1)
    finv.append(1)
    finv.append(1)
    inv.append(1)
    inv.append(1)
    for i in range(1)"""

ans = 0
for j in range(N):
    for i in range(j):
        ans = ans%(10**9+7) + 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()))
s = 0
for i in range(len(a)-1):
  s_tmp = sum(a[i+1:len(a)])
  s += a[i] * s_tmp
print(s % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

N = int(input())
A = list(map(int,input().split()))
M = 0
for i in range(0,N-1):
  for j in range(i+1,N):
    M = M + A[i]*A[j]
while M >= 1000000007:
  M = M - 1000000007
print(M)

Submission status: Time Limit Exceeded

Solution code:
s = int(input())

num = input()
num = num.split()
 
for i in range(s):
    num[i] = int(num[i])

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    answer = solve(N, A)

    print(answer)


def solve(N, A):
    comb = combinations(A, 2)
    prod = (x * y for x, y in comb)
    return sum(prod) % (10**9 + 7)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A= list(map(int,input().split()))
mod_num = 1.0e+9 + 7
for i in range(len(A)):
  A[i]= A[i]%mod_num
rest = 0
for i in range(N-1):
  for j in range(N-i-1):
    rest +=A[i]*A[i+j+1]
    if(rest>=mod_num):
    	rest=rest%mod_num

    
print(int(rest%mod_num))

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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):
    plus = 0
    for j in range(i, n):
        if i == j:
            continue
        plus += a[j]
    ans += a[i]*plus 
    ans %= MOD
print(ans)

Submission status: Time Limit Exceeded

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

mod = 1000000000 + 7
ans = 0

for i in range(n):
    for j in range(n):
        pdt = 0
        if i<j:
            pdt = a[i] * a[j]
        ans += pdt

ans %= mod
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

r = 0

for n in range(N):
    a = A.pop(0)
    for aa in A:
        r = r + a * aa

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
d = list(map(int, input().split()))
ans = 0
goukei = sum(d)
for i in range(len(d)-1):
  temp = d.pop(0)
  goukei -= temp
  ans += temp * goukei

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

Submission status: Time Limit Exceeded

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

ans = 0
p = list(itertools.combinations(A,2))
for i in range(len(p)):
    ans += p[i][0]*p[i][1]

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

Submission status: Time Limit Exceeded

Solution code:
import sys


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 i in range(n-1):
    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):
    ans += (A[i:i+1][0]*sum(A[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()))

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

answer = 0
for i in range(len(v)):
    for j in range(i+1, len(v)):
        answer += v[i] * v[j]
        answer %= 10*10*10*10*10*10*10*10*10 + 7

print(answer)

Submission status: Time Limit Exceeded

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

max = (10 ** 9) + 7

sum = 0
for i in range (n-1):
    for j in range (n):
        if i > j:
            continue
        if i != j:
            sum += a[i]*a[j]
        if sum > max:
            sum = sum % max


print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
mod = int(1e9 + 7)
re = {}
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:
import numpy as np

N = int(input())
B = np.array(list(map(int, input().split())))

sum_ = 0
for i in range(N-1):
    sum_ = sum_ + sum(B[i]*B[i+1:])
    
result = pow(int(sum_), 1, (10**9+7))
print(result)

Submission status: Time Limit Exceeded

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