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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
m = 1000000007

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

ans = s % m
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0

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

print(ans % 1000000007)

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans % 1000000007)

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
r_wa = list()
for i in range(n+1) :
  r_wa.append(sum(a[:i+1]))

for i in range(n-1) :
  ans += a[i]*(r_wa[n]-r_wa[i])
  ans = ans%1000000007
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a = input()
b = list(map(int,input().split()))
m = 10**9 + 7
total = 0
for x in range(len(b)-1):
	for y in range(x+1,len(b)):
		total=((b[x]*b[y]) + total)%m


print(total)

Submission status: Time Limit Exceeded

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

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''
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]
        if ans>10**9+7:
            ans%=10**9+7
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = list(map(int, input().split()))
A.sort()
sums = 0
for i in range(n):
  for j in range(n):
    sums += A[i]*A[j]
    
summ = 0
for i in range(n):
  summ += A[i]**2
  
tot = (sums-summ)/2
print(int(tot)%1000000007)

Submission status: Time Limit Exceeded

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

sum=0
tmp=0
for i in range(n):
    o = i+1
    tmp = 0
    while (o<n):
        tmp=a[o]+tmp
        o=o+1
    sum=(a[i]%1000000007*tmp%1000000007)%1000000007+sum%1000000007

print(sum%1000000007)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
nums = list(map(int,input().split()))
sum = 0
 
for i in range(len(nums)):
  i_a = nums[0]
 
  #print(i_a,"=かけられる数")
  del nums[0]
  #print("削除後",nums)
 
  for j in range(len(nums)):
    #print("かけられる数",i_a,"かける数",nums[j])
    sum += i_a * nums[j]
 
 
print(sum%1000000007)

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

Submission status: Time Limit Exceeded

Solution code:
m = 1000000007

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

for i in range(n-1):
    for j in range(i+1,n):
        #print(a[i],a[j])
        s.append(a[i]*a[j])

ans = sum(s) % m
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
x = 10 ** 9 + 7

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

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


print(ans % x)

Submission status: Time Limit Exceeded

Solution code:
x = 10 ** 9 + 7

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

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

print(ans % x)

Submission status: Time Limit Exceeded

Solution code:
N = int(input().split()[0])
a_list = list(map(int, input().split()))

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

Submission status: Time Limit Exceeded

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

N = int(input().split()[0])
a_list = list(map(int, input().split()))


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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

limit=10**9+7

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

limit=10**9+7

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

for i in range(n):
    b.append(a[i])
    ans += a[i]*(sum(a)-sum(b))

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

Submission status: Time Limit Exceeded

Solution code:
import copy
import math
import time
import statistics
import math
import itertools
import bisect
import sys
from decimal import *
from collections import deque


def get_int():
    return int(input())

def get_string():
    return input()

def get_int_list():
    return [int(x) for x in input().split()]

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

def get_int_multi():
    return map(int, input().split())

def get_string_char_list():
    return list(str(input()))

# print("{} {}".format(a, b))
# a_list = [0] * a
sys.setrecursionlimit(10 ** 6)

def main():
    start = time.time()

    n = get_int()
    a = get_int_list()

    ansmod = 10 ** 9 + 7

    ans = 0
    for i in range(len(a)):
        wk = 0
        for ii in range(i+1, len(a)):
            wk += a[ii]
            #ans = (a[i] * a[ii] + ans) % ansmod

        ans = (ans + a[i] * wk) % ansmod

    print(ans)


if __name__ == '__main__':
    main()

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

Submission status: Time Limit Exceeded

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

gokei = 0
for i in range(len(A)):
    gokei += A[i] * sum(A)
    gokei -= A[i] * A[i]
gokei = gokei // 2
ans = gokei % 1000000007
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

mod = 10 ** 9 + 7
total = 0
y = sum(list1)

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

total = total % mod
print(total)

Submission status: Time Limit Exceeded

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

mod = 10 ** 9 + 7
total = 0

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

total = total % mod
print(total)

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

Submission status: Time Limit Exceeded

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

ans = 0
den = int(1e9 + 7)
for i in range(len(a) - 1):
    ans = (ans + a[i] * sum(a[i + 1:])) % den

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split(" ")))
 
ans = 0
den = int(1e9 + 7)
for i in range(len(a)):
    for j in range(i + 1, len(a)):
        ans = (ans + a[i] * a[j]) % den

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split(" ")))
 
ans = 0
den = int(1e9 + 7)
for i in range(len(a)):
    for j in range(i + 1, len(a)):
        ans = (ans + (a[i] * a[j]) % den) % den

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
den = int(1e9 + 7)
for i in range(len(a)):
    for j in range(i + 1, len(a)):
        ans = (ans + ((a[i] % den) * (a[j] % den) % den)) % den

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
A_str = input()
A_str_list = A_str.split()
A = [int(A_str_list[i]) for i in range(N)]
sum = 0
for i in range(N):
    for j in range(N-i-1):
        # print(i+j+1, A[i+j+1])
        mod = np.mod(A[i]*A[i+j+1], np.power(10, 9)+7)
        sum += mod
print(np.mod(sum, np.power(10, 9)+7))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
x = list(map(int, input().split()))
s = 0

for i in range(N-1):
  for j in range(i+1,N):
    s = s + x[i]*x[j]
s = s % 1000000007

print(s)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(len(nums)):
    for j in range(i+1,len(nums)):
        k = (nums[i] * nums[j])
        total += k
print(total % (10**9+7))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = tuple(map(int,input().split()))
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()))
#A=[int(x) for x in input().split()]
i = 0
j = 0
S = 0
while i < N:
    j = i + 1
    while j < N:
        S += (A[i] )*(A[j] )
        j += 1
    i += 1
print((S % 1000000007))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ar = list(map(int,input().split(" ")))
count = 0
for i in range(n-1):
    br = ar[i+1:n]
    count += ar[i] * sum(br)
print(count % (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(N):
    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()))
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()))

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

Submission status: Time Limit Exceeded

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

for i in range(n-1):
    x = 0
    for j in range(i+1, n):
        x += a[j]
    x = x%mod
    y = a[i]* x
    sumpro += y

print(sumpro%mod)

Submission status: Time Limit Exceeded

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

sum=0
tmp=0
for i in range(n):
    o = i+1
    tmp = 0
    while (o<n):
        tmp=((a[o]%1000000007)+(tmp%1000000007))%1000000007
        o=o+1
    sum=(a[i]*tmp)%1000000007+sum%1000000007

print(sum%1000000007)

Submission status: Time Limit Exceeded

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

for i in range(n-1):
    x = 0
    for j in range(i+1, n):
        x += a[j]
    x = x%mod
    y = a[i]* x
    if y > mod:
        y = y%mod
    sumpro += y
    if sumpro > mod:
        sumpro = sumpro%mod
print(sumpro)

Submission status: Time Limit Exceeded

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

sum=0
tmp=0
for i in range(n):
    o = i+1
    tmp = 0
    while (o<n):
        tmp=a[o]+tmp
        o=o+1
    sum=(a[i]*tmp)+sum

print(sum%1000000007)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

res = 0
for i in range(len(a)):
    for j in range(i+1, len(a)):
        res = (res+((a[i]*a[j])%mod))%mod

print(res)

Submission status: Time Limit Exceeded

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

s=0
for i in range(n):
	for j in range(i+1,n):
		s+=(arr[i]*arr[j])%1000000007
print(s%1000000007)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

A = [int(x) for x in input().split()]

d = 10**9+7
s = 0

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
MOD = 10 ** 9 + 7

n=int(input()) #3
alst=np.array(list(map(int,input().split()))) #[1,2,3]

total=np.sum(alst) #6
sum=0

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

print(sum)

Submission status: Time Limit Exceeded

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

sum=0
for i in range(n):
    o = i+1
    while (o<n):
        sum=(a[i]%1000000007*a[o]%1000000007+sum)%1000000007
        o=o+1

print(sum)

Submission status: Time Limit Exceeded

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

sum=0
for i in range(n):
    o = i+1
    while (o<n):
        sum=(a[i]*a[o]+sum)%1000000007
        o=o+1

print(sum)

Submission status: Time Limit Exceeded

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

sum=0
for i in range(n):
    o = i+1
    while (o<n):
        sum=a[i]*a[o]+sum
        o=o+1

print(sum%1000000007)

Submission status: Time Limit Exceeded

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

ans=0
total=0

for i in range(n):
  l=i+1
  for l in range(i+1,n):
   
    ans=ans+x[l]
  total=total+x[i]*ans
  ans=0 
   
    
print(total %1000000007)

Submission status: Time Limit Exceeded

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

    mod = 10 ** 9 + 7
    ans = 0

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

    ans = ans % mod
    print(ans)

if __name__ == '__main__':
    abc177_c_1()

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

print(SUM)

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())
A_list = list(map(int, input().split()))
A_list.insert(0, 0)
product_dict = {}
for i, j in itertools.combinations(range(len(A_list)), 2):
    product_dict[str(i) + "&" + str(j)] = A_list[i] * A_list[j]

sum = 0
for i in range(1, N):
    for j in range(i + 1, N + 1):
        sum += product_dict[str(i) + "&" + str(j)]
        sum = sum % 1000000007
print(sum)

Submission status: Time Limit Exceeded

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

def Calc(a: int, b: int) -> int:
    return (a * b) % m

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:

n = int(input())
ns = list(map(int, input().split(" ")))


m = 10 ** 9 + 7

sm = 0
for i in range(n):
    for j in range(i+1, n):
        sm += (ns[i] * ns[j])

sm %= m

print(sm)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

print(sumpro % 1000000007)

Submission status: Time Limit Exceeded

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

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

print(sumpro % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
def mod(num):
  return num%(1000000007)

N = int(input())
L = list(map(mod, map(int, input().split())))

L.sort()

result = 0
for i in range(N-1):
  for j in range(i+1, N):
    result += mod(L[i]*L[j])
  result = mod(result)
print(result)

Submission status: Time Limit Exceeded

Solution code:
def mod(num):
  return num%(10**9+7)

N = int(input())
L = list(map(mod, map(int, input().split())))

L.sort()

result = 0
for i in range(N-1):
  for j in range(i+1, N):
    result = mod(result + L[i]*L[j])
print(result)

Submission status: Time Limit Exceeded

Solution code:
def mod(num):
  return num%(10**9+7)

N = int(input())
L = list(map(mod, map(int, input().split())))

L.sort()

result = 0
for i in range(N-1):
  for j in range(i+1, N):
    result += mod(L[i]*L[j])
  result = mod(result)
print(result)

Submission status: Time Limit Exceeded

Solution code:
def mod(num):
  return num%(10**9+7)

N = int(input())
L = list(map(mod, map(int, input().split())))

L.sort()

result = 0
for i in range(N-1):
  for j in range(i+1, N):
    result += mod(L[i]*L[j])
    result = mod(result)
print(result)

Submission status: Time Limit Exceeded

Solution code:
def mod(num):
  return num%(10**9+7)

N = int(input())
L = list(map(mod, map(int, input().split())))



result = 0
for i in range(N-1):
  for j in range(i+1, N):
    result += mod(L[i]*L[j])
    result = mod(result)
print(result)

Submission status: Time Limit Exceeded

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

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

result = 0
for i in range(N-1):
  for j in range(i+1, N):
    result += mod(L[i]*L[j])
    result = mod(result)
print(result)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

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

comb = combinations(As, 2)
def multiply(l):
  return l[0] * l[1]

out = sum(map(multiply, comb))

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())
A = list(map(int,(input().split())))
Asum = 0
c_list = list(itertools.combinations(A, 2))

for l in c_list:
    Asum = Asum + l[0]*l[1]

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

Submission status: Time Limit Exceeded

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

num = 0
j = 0

for i in range(N):
  for j in range(i+1, N):
    a = s[i] * s[j]
    num += a

b = num % (10**9 + 7)    
print(b)