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: Wrong Answer

Solution code:
import numpy
def resolve():
    n = int(input())
    a = tuple(map(int,input().split()))
    N = 10**9+7
    cumsum_a = numpy.cumsum(a[::-1])
    ans = 0
    for i in range(n-1):
        ans += a[i]*cumsum_a[n-i-2]
        ans %= N
    print(ans)
resolve()

Submission status: Wrong Answer

Solution code:
num = int(input(""))
val = list(map(int,input().split()))
val_sum = 0
mod = 10**9 + 7

for i in range(num):
    for j in range(i+1,num):
        val_sum = val_sum + ((val[i]*val[j])%mod)
        
print(val_sum)

Submission status: Wrong Answer

Solution code:
n = int(input())
mod = 10**9 + 7
a = [int(x)%mod for x in input().split()]
allsum = sum(a)
s = 0
for i in range(n):
    allsum = allsum -a[i]
    s += a[i]*allsum
print(s)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(len(a)-1):
  for j in range(i+1, len(a)):
    temp = a[i] * a[j]
    sum += temp

answer = sum % mod
print(sum)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = np.sum(A)- np.sum(A*A)

print(ans//2%mod)

Submission status: Wrong Answer

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

for i in range(N):
    sum += A[i]%mod
sum = (sum**2)%mod

for j in range(N):
    sum_1 += (A[j]**2)%mod
sum2=sum-sum_1
if sum2<0:
    sum2+=mod
ans=(sum2/2)%mod
print(int(ans))

Submission status: Wrong Answer

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

for i in range(N):
    sum += A[i]
    sum%=mod
sum = (sum**2)%mod

for j in range(N):
    sum_1 += A[j]**2
    sum_1%=mod
sum2=sum-sum_1
if sum2<0:
    sum2+=mod
ans=(sum2/2)%mod
print(int(ans))

Submission status: Wrong Answer

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

for i in range(N):
    sum += A[i]
    sum%=mod
sum = (sum**2)%mod

for j in range(N):
    sum_1 += A[j]**2
    sum_1%=mod

ans = (sum - sum_1)/2
ans = ans%mod

print(int(ans))

Submission status: Wrong Answer

Solution code:
s = input()
t = input()

res = 0
for i in range(len(s)-len(t)+1):
    tmp = 0
    for j in range(len(t)):
        if s[j+i] == t[j]:
            tmp += 1
    res = max(res, tmp)

print(len(t)-res)

Submission status: Wrong Answer

Solution code:
n = int(input())
L = list(map(int,input().split()))
sub_area = 0
area_len = 0

for i in range(n):
  sub_area += L[i]**2
  area_len += L[i]

ans = ((area_len**2 - sub_area) / 2) % (10**9+7)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy
n=int(input())
l=list(map(int, input().split()))
res=0
mod=10**9+7
l.append(0)
l.reverse()
cum=numpy.cumsum(l)
for i in range(n):
    res+=(l[n-i]*cum[n-i-1])%mod
print(res%mod)

Submission status: Wrong Answer

Solution code:
import numpy
n=int(input())
l=list(map(int, input().split()))
res=0
l.append(0)
l.reverse()
cum=numpy.cumsum(l)
for i in range(n):
    res+=l[n-i]*cum[n-i-1]
print(res%(10**9+7))

Submission status: Wrong Answer

Solution code:
import numpy
n=int(input())
l=list(map(int, input().split()))
res=0
l.append(0)
l.reverse()
cum=numpy.cumsum(l)
for i in range(len(l)):
    res+=l[len(l)-1-i]*cum[len(l)-i-2]
print(res%(10**9+7))

Submission status: Wrong Answer

Solution code:
import numpy
n=int(input())
l=list(map(int, input().split()))
res=0
l.append(0)
l.reverse()
cum=numpy.cumsum(l)
for i in range(n+1):
    res+=l[n-i]*cum[n-i-1]
print(res%(10**9+7))

Submission status: Wrong Answer

Solution code:
import numpy
n=input()
l=list(map(int, input().split()))
res=0
#print(f"le{len(l)}")
l.append(0)
l.reverse()
for i in range(len(l)): 
    print(l[len(l)-1-i],numpy.cumsum(l)[len(l)-i-2])
    res+=l[len(l)-1-i]*numpy.cumsum(l)[len(l)-i-2]
    #print(f"{res}レス")
print(res%(10**9+7))
#print(res)

Submission status: Wrong Answer

Solution code:
import numpy
n=input()
l=list(map(int, input().split()))
res=0
#print(f"le{len(l)}")
l.append(0)
l.reverse()
for i in range(len(l)): 
    print(l[len(l)-1-i],numpy.cumsum(l)[len(l)-i-2])
    res+=l[len(l)-1-i]*numpy.cumsum(l)[len(l)-i-2]
    print(f"{res}レス")
print(res%(10**9+7))
#print(res)

Submission status: Wrong Answer

Solution code:
n=input()
l=list(map(int, input().split()))
res=0
#print(f"le{len(l)}")
for i in range(len(l)):
    for j in range(i+1,len(l)):
        res+=l[i]*l[j]
        #print(res)
print(res)

Submission status: Wrong Answer

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

for i in range(N):
    sum += A[i]
sum = sum**2

for j in range(N):
    sum_1 += A[j]**2

ans = (sum - sum_1)/2
ans = ans%mod

print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7

s = sum(arr) % mod

result = 0
for i in arr:
  s -= i
  s %= mod
  result += s
  result %= mod
print(result)

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7

slist = sum(arr)

result = 0
for i in arr:
  result += i * (slist - i)
  result %= mod
print(result)

Submission status: Wrong Answer

Solution code:
# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

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

val = 0
for a in A:
    val += a * sumA
    val %= MOD
for a in A:
    val -= a * a
    val %= MOD
val //= 2
print(val)

Submission status: Wrong Answer

Solution code:
def main():
    MOD = 10**9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    a_sum = sum(a)
    ans = 0
    
    for i in range(n):
        ans += a[i] * (a_sum - a[i])
        ans %= MOD
    print(ans//2)
        
        
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
d = 1000000007
n = int(input())
a = list(map(int, input().split()))
summation = sum(a) % d
diagonal = 0
for i in range(len(a)):
        diagonal += a[i] ** 2 
ans = (((summation  ** 2) - diagonal) // 2) % d
print(ans)

Submission status: Wrong Answer

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

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

print(K%m)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

print(K)

Submission status: Wrong Answer

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

M = 10**9 + 7

Total = sum(A) -A[0]

ans = 0

for i in range(N-1):
    ans += A[i] * Total
    ans % M
    Total -= A[i+1]

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

sum = 0
B = []
B.append(0)

for t in range(N):
    B.append(A[t] + B[t])
    
B.remove(0)
    
print(B)
    
for i in range(N):
    sum += A[i] * (B[N-1] - B[i])
            
        
print(sum % (10**9+7))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
mod = 10 ** 9 + 7

mod = 10 ** 9 + 7


def main():
    n = int(input())
    ls = list(map(int, input().split()))

    ans = 0

    sm = sum(ls)

    for i in range(n):
        ans += ls[i] * sm % mod

    sub = 0
    for i in range(n):
        sub += ls[i] * ls[i] % mod

    ans -= sub % mod

    ans = ans // 2

    print(ans % mod)


main()

Submission status: Wrong Answer

Solution code:
import numpy


def CUSUM(lst: list) -> list:
    k = [val + k[index-1] if index != 0 else lst[0]
         for index, val in enumerate(lst)]
    return k


def solve1(n: int, a: list) -> int:
    mod = 10**9 + 7
    ans = 0
    list_len = len(a)
    cusum = numpy.cumsum(a, dtype="int64")

    for i in range(1, list_len):
        ans += a[i-1] * (cusum[list_len-1] - cusum[i-1])
        ans %= mod
        
        """
        print(a[i-1], "*",
              (cusum[list_len-1] - cusum[i-1]), "=",
              a[i-1] * (cusum[list_len-1] - cusum[i-1]) % mod, sep=" ")
        """

    return ans % mod


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

print(solve1(n, a))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

mod = 10**9 + 7

A = np.array(A)

sum1 = A.sum()
sum2 = (A**2).sum()

ans = (sum1**2 - sum2) //2

print(ans%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

mod = 10**9 + 7

A = np.array(A)

ans = ( (A.sum()**2) - ((A**2).sum()) )  // 2

ans = ans % mod

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
A=np.array(list(map(int,input().split())))/10**5

ans=np.sum((np.array([(A[x]*A[y]) for x in np.array(range(0,N-1)) for y in np.array(range(x+1,N))])))

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

Submission status: Wrong Answer

Solution code:
N = int(input())
values = input().split(' ')
a = [0] * N

mod = 10 ** 9 + 7
for i in range(N):
    a[i] = int(values[i])
a2 = list(map(lambda x: x ** 2, a))
# print(a)
# print(a2)
    
ans = (sum(a) ** 2 - sum(a2)) / 2
ans %= mod
print(int(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
values = input().split(' ')
a = [0] * N

mod = 10 ** 9 + 7
for i in range(N):
    a[i] = int(values[i])
a2 = list(map(lambda x: x ** 2, a))
    
ans = (sum(a) ** 2 - sum(a2)) / 2
ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
mod = 10 ** 9 + 7
import numpy as np
a = list(map(int, input().split()))
s=0
ss=0
for i in range(n):
    if i > 0:
        ss += a[i-1]%mod
    s += ss * a[i] % mod
print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
mod = 10 ** 9 + 7
import numpy as np
a = list(map(int, input().split()))
s=0
ss=0
for i in range(n):
    ss += a[i]%mod
    s += ss * a[i] % mod
print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())

s = input().split(" ")

sumup = 0
for i in s:
  sumup += int(i) 

ans = 0
for i in range(n):
  r = int(i)
  
  sumup -= r
  
  ans += r*sumup
    
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
n = int(input())

s = input().split(" ")

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

Submission status: Wrong Answer

Solution code:

import numpy as np

n = int(input())
al = list(map(int, input().split()))
bl = list(np.cumsum(al))

# print(bl)

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
from numba import njit, i8
import sys
read = sys.stdin.readline
mod = 10 ** 9 + 7


@njit((i8, i8[:]), cache=True)
def main(n, a):
    s = np.cumsum(a)
    ans = 0
    for i in range(1, n):
        ans = (ans + a[i] * s[i - 1]) % mod
    print(ans)


n = int(read())
a = np.fromstring(read(), dtype=np.int64, sep=' ')
main(n, a)

Submission status: Wrong Answer

Solution code:
import numpy as np
from numba import njit, i8
import sys
read = sys.stdin.readline
mod = 10 ** 9 + 7


@njit((i8, i8[:]), cache=True)
def main(n, a):
    s = np.sum(a)
    ans = 0
    for i in range(n):
        ans = (ans + a[i] * (s - a[i])) % mod
    print(ans // 2)


n = int(read())
a = np.fromstring(read(), dtype=np.int64, sep=' ')
main(n, a)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())

al = list(map(int, input().split()))
bl = np.cumsum(al)
ans = 0
for i in range(n):
    ans += al[i]*bl[i]-al[i]**2

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

n = int(input())

li = list(map(int,input().split()))
li_1 = []
mod = 10**9+7

max = sum(li) **2

for i in li:
    li_1.append(i**2)

a = int((max - sum(li_1)) / 2)

print(a%mod)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
s = 0
while len(a) != 1:
    firstnum = a.pop()
    for i in a:
        b = firstnum * i
        s += b
print(s)

Submission status: Wrong Answer

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

S = sum(A)%mod
S = pow(S, 2, mod)
T = 0
for a in A:
    T+=pow(a, 2, mod)
    T %= mod

S -= T
S %= mod
S //= 2

print(S)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int,input().split())
total=0
for i in range(1,N+1):
  try:
    sumA = A[i-1]*sum(A[i:])
    total+=sumA
  except:
    pass
print(total)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int,input().split())
total=0
for i in range(N):
  try:
    sumA = A[i]*sum(A[i+1:])
    total+=sumA
  except:
    pass
print(total)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

arr = np.array(A)
K = np.inner(arr, arr)
P = pow(sum(A), 2)
ans = ((P-K)/2)%mod

print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

arr = np.array(A)
K = np.inner(arr, arr)
P = pow(sum(A), 2)
ans = ((P-K)/2)%mod

print(ans)

Submission status: Wrong Answer

Solution code:
#abcdef
#a*b,a*c,a*d,a*e,a*f
#b*c,b*d,b*e,b*f
#c*d,c*e,c*f
#d*e,d*f
#e*f

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

mod = 10**9 + 7
all_l = 0
for i in range(n):
    all_l += l[i]
    all_l %= mod

ans = 0
for i in range(n):
    ans = ans + l[i]*((all_l-l[i])%mod)%mod
    ans %= mod
print(ans//2)

Submission status: Wrong Answer

Solution code:
#abcdef
#a*b,a*c,a*d,a*e,a*f
#b*c,b*d,b*e,b*f
#c*d,c*e,c*f
#d*e,d*f
#e*f

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

mod = 10**9 + 7
all_l = 0
for i in range(n):
    all_l += l[i]
    all_l %= mod

ans = 0
for i in range(n):
    ans = ans + l[i]*((all_l-l[i])%mod)
    ans %= mod
print(ans//2)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

Submission status: Wrong Answer

Solution code:
n=int(input())
L=list(map(int,input().split()))
s=0
t=0
p=10**9+7
x=5*10**4+4
for i in range(0,n):
  s=(s+L[i])%p
  t=(t+L[i]*L[i])%p
ans=(x*(s*s-t))%p
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import itertools
N = int(input())
A = list(map(int, input().split()))
sm=0
mod=10**9+7
for i in itertools.combinations(A,2):
    sm+=(i[0]*i[1])%mod
    sm%mod

print(sm)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
input()
a = list(map(int, input().split()))
c = 1000000007
print(int(((sum(a)**2-sum(map(lambda x: x**2, a)))/2)%c))

Submission status: Wrong Answer

Solution code:
input()
a = list(map(int, input().split()))
c = 1000000007
print(((sum(a)**2-sum(map(lambda x: x**2, a)))/2)%c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N == 2:
    print((A[0]*A[1])%(10**9+7))
B = [0]*(N-1)
B[N-2] = A[N-1]

for i in range (3, N+1):
    B[N-i]=B[N-i+1]+A[N-i+1]

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input()

a = list(map(int, A.split(" ")))

cur_ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        print(str(i) + " " + str(j))
        cur_ans += a[i]*a[j]
        cur_ans = cur_ans % (1000000000 + 7)

print(cur_ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
p=a[0]*a[n-1]
for i in range(n):
   if i<=n-2:
    p+=a[i]*a[i+1]
print(p)

Submission status: Wrong Answer

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]

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

print(sum)

Submission status: Wrong Answer

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

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

ans = ans % 10**9+7

print(int(ans))

Submission status: Wrong Answer

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

ans = 0
S = sum(A)
for i in range(N):
    ans += A[i] * S - A[i]**2

ans = (ans/2) % 1000000007


print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
input();m=10**9+7;s=sum(A:=[*map(int,input().split())])%m;print((s*s-sum(a**2for a in A))//2%m)

Submission status: Wrong Answer

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

sum_A = sum(A)

ans = 0
for i in range(N):
  a = A[i]
  sum_A-=a
  ans+=a*sum_A
print(ans)

Submission status: Wrong Answer

Solution code:
input()
a = map(int,input().split())
aa=0
b=0
for i in a:
    aa+=i
    b+=i**2
aa**=2
print(int(((aa-b)/2)%1000000007))

Submission status: Wrong Answer

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

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

mass = [0]*(N+1)
for i in range(N):
    mass[i+1] = mass[i] + A[i]
print(mass)
answer = 0
for i in range(N-1):
    answer += (A[i]*(mass[N]-mass[i+1]))
    print(answer)

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

Submission status: Wrong Answer

Solution code:
"""C."""

import sys

input = sys.stdin.readline  # noqa: A001

n = int(input())
a = list(map(int, input()[:-1].split(' ')))

result = 0

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

Submission status: Wrong Answer

Solution code:
"""C."""

import sys

input = sys.stdin.readline  # noqa: A001

n = int(input())
a = list(map(int, input()[:-1].split(' ')))

result = 0

for i, v1 in enumerate(a):
    for j, v2 in enumerate(a):
        if i < j:
            result += v1 * v2
print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
total = 0
sub = 0
for i in a:
    total += i
    sub += i * i
print(((total * total) - sub) // 2)

Submission status: Wrong Answer

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

s = 0
for i in range(N):
    s += a[i] 
Sum = pow(s, 2) 
for i in range(N):
    Sum -= pow(a[i], 2)
Sum /= 2

print(int(Sum) % 1000000007)

Submission status: Wrong Answer

Solution code:
import numpy
N=int(input())
A=input()
A=A.split()
for i in range(N):
  A[i]=int(A[i])

a=numpy.cumsum(A)
m=a[N-1]
b=0
for j in range(N):
  b+=A[j]*(m-a[j])
  
MOD=10**9+7
print(b%MOD)

Submission status: Wrong Answer

Solution code:
import numpy
N=int(input())
A=input()
A=A.split()
for i in range(N):
  A[i]=int(A[i])

a=numpy.cumsum(A)
b=0
for j in range(N):
  b+=A[j]*(a[N-1]-a[j])
 
  
MOD=10**9+7
print(b%MOD)

Submission status: Wrong Answer

Solution code:
import numpy
N=int(input())
A=input()
A=A.split()
B=[]
for i in range(N):
  A[i]=int(A[i])

  
a=numpy.cumsum(A)
b=0
for j in range(N):
  b+=A[j]*(a[N-1]-a[j])
 
  
MOD=1000000007  
print(b%MOD)

Submission status: Wrong Answer

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

ans=0

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

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

print(ans/2)

Submission status: Wrong Answer

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

ans=0

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

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

print(ans/2)

Submission status: Wrong Answer

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

sum_of_product = sum(A) ** 2

for i in A:
    sum_of_product -= i ** 2

sum_of_product = (sum_of_product / 2) % (10 ** 9 + 7)

print(sum_of_product)

Submission status: Wrong Answer

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

sum_of_product = (sum(A) ** 2)

for i in A:
    sum_of_product -= i ** 2

sum_of_product = (sum_of_product / 2) % 10 ** 9 + 7

print(sum_of_product)

Submission status: Wrong Answer

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

sum_of_product = (sum(A) ** 2)

for i in A:
    sum_of_product -= i ** 2

sum_of_product %= 10 ** 9 + 7

print(sum_of_product)

Submission status: Wrong Answer

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

sum_of_product = (sum(A) ** 2) % (10 ** 9 + 7)

for i in A:
    sum_of_product -= i ** 2
    if sum_of_product < 0:
        sum_of_product += 10 ** 9 + 7

print(sum_of_product)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
mod = 10**9+7

total = 0
for i in range(N):
    total += (A[i] % mod)**2 % mod

print(int(((sum(A) % mod)**2 % mod - total % mod) % mod/2))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
mod = 10**9+7

total = 0
for i in range(N):
    total += A[i]**2 % mod

print(int(((sum(A) % mod)**2 % mod - total % mod) % mod/2))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
mod = 10**9+7

total = 0
for i in range(N):
    total += A[i]**2 % mod

print(int((sum(A)**2 % mod - total % mod) % mod/2))

Submission status: Wrong Answer

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

total = 0
for i in range(N):
    total += A[i]**2
mod = 10**9+7
print(int((sum(A)**2 % mod - total % mod) % mod/2))

Submission status: Wrong Answer

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

total = 0
for i in range(N):
    total += A[i]**2
print(int((sum(A)**2 - total)/2 % (10**9+7)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
b=sum(a)
score=0
for i in range(len(a)):
  b -= a[i]
  score=a[i]*b
  
print(score)

Submission status: Wrong Answer

Solution code:
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
J=int(1e9)+7

###############################################################################\n=17
n=int(input())
A=INPUT()
sum=0
for i in range(n):
    sum+=A[i]
sum=sum*sum

s=0
for i in range(n):
    s+=A[i]**2

ans=(sum-J)//2
ans%=J
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
J=int(1e9)+7

###############################################################################\n=17
n=int(input())
A=INPUT()
sum=0
for i in range(n):
    sum+=A[i]
    sum%=J
sum=sum*sum
sum%=J
s=0
for i in range(n):
    s+=A[i]**2
    s%=J 
ans=sum-s
ans%=J
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
score=0
score_y=0
score_big=0
all=sum(a)
score_big=all**2
for i in range(0,n):
  score_y += a[i]**2
score = math.floor((score_big-score_y)/2)
print(score%mod)

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
score=0
score_y=0
score_big=0
all=sum(a)
score_big=all**2


for i in range(0,n):
  score_y += a[i]**2

score = math.floor((score_big-score_y)/2)
print(score%mod)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(sum)

Submission status: Wrong Answer

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

mod = 10**9 + 7
total =sum(an)
ans = 0

for x in range(n-1):
  nokori = total-sum(an[:x+1])
  ans += an[x] * nokori % mod

    
    
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
a = (sum(A)**2) %(10**9+7)
b =  sum([(a**2) %(10**9+7) for a in A])
print(((a-b)%(10**9+7))//2)

Submission status: Wrong Answer

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

sumA = sum(A)
ans = 0
for i in range(len(A)):
    sumA = sumA - A[i]
    ans += A[i] * sumA
    ans = int(ans % (math.pow(10,9)+7))


ans = int(ans % (math.pow(10,9)+7))
print(ans)

Submission status: Wrong Answer

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

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

ans = int(ans % (math.pow(10,9)+7))
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
re = 0
re2 = 0

for i in range(n):
    re = a[i]*sum(a[i+1:])
    #for m in range(n-i-1):
        #re = a[i]*a[i+m+1]
        #re2 += re

ans = re %1000000007
print(ans)

Submission status: Wrong Answer

Solution code:
h = int(input())
a = list(map(int,input().split()))
ruiseki = 0
ans = 0
for i in range(h-2,-1,-1):
    ruiseki += a[i+1]
    ans += ruiseki * a[i]
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

zt=sum(A)**2
A=np.array(A)
A=A**2
tk=sum(A)

ans=(zt-tk)//2

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
def productSum(A,n) -> int:
    MOD = 1000000007
    sum_arr = 0
    for i in range(n):
        sum_arr += A[i]
        sum_arr %= MOD
    sum_arr_sq = (sum_arr*sum_arr)%MOD
    indiv_sq_sum = 0
    for i in range(n):
        indiv_sq_sum += (A[i]*A[i])
        indiv_sq_sum %= MOD
    ans = ((sum_arr_sq - indiv_sq_sum))//2
    ans %= MOD
    return ans

n = int(input())
arr = [int(x) for x in input().split()]
print(productSum(arr,n))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
re = 0
for i in range(n):
    for m in range(n-i):
        re += a[i]*a[i+m]

ans = re %1000000007
print(ans)

Submission status: Wrong Answer

Solution code:
a = input()
b = input()
ind = []
for i in range(len(a)-len(b)):
  if a[i] == b[0]:
    ind.append(i)

ans = len(b)
for i in range(len(ind)):
  count = 0
  for j in range(len(b)):
    if a[ind[i]+j]!=b[j]:
      count += 1
  ans = min(ans,count)

print(ans)

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
from bisect import bisect_right

n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7

for i in range(0, n):
    lst = deepcopy(a[i+1:])
    lst.sort()
    idx = bisect_right(lst, a[i])
    ans += (a[i] * sum(lst[idx:])) % mod
print(ans)