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:
N = int(input())
As = [int(v) for i, v in enumerate(input().split())]
listA = []
for i in range(len(As)):
    listA.append(int(As[i]))
ans = 0
for i in range(len(listA) - 1):
    for j in range(i + 1, len(listA)):
        if listA[i] != listA[j]:
            ans += listA[i] * listA[j]
print(str(ans % 1000000007))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
sum = A.sum()
sum2 = (A**2).sum()
ans = int(((A.sum())**2 - sum2)/2) % (10**9+7)
print(ans)

Submission status: Wrong Answer

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


def findProductSum(A, n):

    # calculating array sum (a1 + a2 ... + an)
    array_sum = 0
    for i in range(n):
        array_sum = ((array_sum)%mod + A[i])%mod

    # calcualting square of array sum
    # (a1 + a2 + ... + an)^2
    array_sum_square = array_sum * array_sum

    # calcualting a1^2 + a2^2 + ... + an^2
    individual_square_sum = 0
    for i in range(n):
        individual_square_sum += (A[i] * A[i])%mod

    # required sum is (array_sum_square -
    # individual_square_sum) / 2
    return (((array_sum_square -
            individual_square_sum))%mod / 2)%mod

ans = (int(findProductSum(a, n)))%mod
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import numpy as np

n = int(input())
A = [int(a) for a in input().strip().split()]
s = sum(A)
S = 0
mod = 2000000000+14
for a in A:
    S += ((s-a)*a)%mod
S = S//2
print(S)

Submission status: Wrong Answer

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

s_1 = 0
s_2 = 0
for i in range(n):
    s_1 += a[i]
    s_2 += a[i] * a[i]
s = (s_1 * s_1 - s_2) / 2
print(s % (pow(10, 9) + 7))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
#437235829 mod(10^9+7)
sumAcol=0
sumA=0
sumtr=0
for i in range(N):
  sumtr+=A[i]**2
  sumAcol+=A[i]
for i in range(N):
  sumA+=sumAcol*A[i]
sumA=int((sumA-sumtr)/2)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int, input().split()))
m = 10**9 + 7
result = 0
b = 0
for i in range(N):
  b += pow(As[i], 2, m)
a = pow(sum(As), 2, m)
print(int(((a - b) % m) / 2))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)
mod=int(1e9)+7
def SumOfProductOfAllPairArrayElement(arr):
    su=0
    ans=0
    for x in arr:
        su=su+x
    for x in arr:
        ans=(ans%mod+(x%mod*(su-x)%mod)%mod)%mod
    return (ans//2)%mod

 
def main():
    n=int(input())
    vals = list(map(int,input().split(" ")))
    print(SumOfProductOfAllPairArrayElement(vals))


#-----------------------------BOSS-------------------------------------!
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
tmp=0
ans=0
for i in range(n-1):
    tmp=tmp+a[(i+1)*-1]
    ans=(ans+a[(i+2)*-1]*tmp)%(10**9+7)
print(ans)

Submission status: Wrong Answer

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

sums = 0
sums_root = 0

for i in range(N):
  sums += A[i]
  sums_root += A[i] * A[i]

MOD = 1000000007

print(int((((sums * sums) - sums_root) / 2) % MOD))

Submission status: Wrong Answer

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

mod = 10**9 + 7
ans = 0
A = 0
B = 0
for i in range(n):
    A += a[i]
    B += a[i] ** 2
    B %= mod
A %= mod
A2 = A**2 % mod
ans = (A2 - B) % mod
ans //= 2
print(ans)

Submission status: Wrong Answer

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

for k in range(n):
    if a[k]>10**5:
        a[k]=(10**9+7)-a[k]
    
    
b=[]
for i in range(n-1):
    for j in range(i+1,n):
        b.append(a[i]*a[j])
print(sum(b)%(10**9+7))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

readline = sys.stdin.readline
read = sys.stdin.read
MOD = 10**9 + 7

n = int(input())
a = np.array(readline().split(), dtype=np.uint64)
r = np.cumsum(a[::-1])[::-1]
r &= MOD
x = a[:-1] * r[1:]
x %= MOD
ans = np.sum(x) % MOD
print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
num=input().split()
sq=[]
for i in range(n):
  num[i]=int(num[i])
  sq.append(num[i]*num[i])
total=sum(num)
total=total*total
sqtotal=sum(sq)
print((total-sqtotal)/2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import product
n=int(input())
l=list(map(int,input().split()))
m=list(product(l,l))
N=(10**9)+7
ans=0
for i in range(len(m)):
    if m[i][0]!=m[i][1] and m[i][0]<m[i][1]:
        ans+=m[i][0]*m[i][1]%N

print(ans%N)

Submission status: Wrong Answer

Solution code:
mod = ((10**9)+7)
def findProductSum(A, n): 
    array_sum = 0
    for i in A: 
        array_sum = (array_sum + i)%mod
    array_sum_square = (array_sum * array_sum)%mod
    individual_square_sum = 0
    for i in A: 
        individual_square_sum = (individual_square_sum + (i * i)%mod)%mod
    tmp = ((array_sum_square - individual_square_sum)%mod) // 2
    return tmp
n = int(input())
lis = list(map(int,input().split()))
print(findProductSum(lis,n))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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(a)
print(ans)

Submission status: Wrong Answer

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

MOD = 1000000007

sum_all = 0
for i in range(len(a)):
    sum_all += a[i]
#sum_all %= MOD
sum = 0
#print(sum_all)
for i in range(len(a)):
    X = (sum_all - a[i])
    Y = a[i]
    sum += (X*Y)
    sum %= MOD
print(int(sum/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]
s = s**2
for i in range(N):
  s -= a[i]*a[i]
s = int(s/2)
while s >= 10**9 +7:
  s = s % (10**9 +7)
print(int(s))

Submission status: Wrong Answer

Solution code:

N = int(input())
li = list(map(int, input().split()))
MOD_NUMBER = 10**9+7
ans = 0
nizyo_list = [i**2 for i in li]

print(int((sum(li)**2-sum(nizyo_list))/2 % MOD_NUMBER))

Submission status: Wrong Answer

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


def findProductSum(A, n):

    # calculating array sum (a1 + a2 ... + an)
    array_sum = 0
    for i in range(0, n, 1):
        array_sum = ((array_sum)%mod + A[i])%mod

    # calcualting square of array sum
    # (a1 + a2 + ... + an)^2
    array_sum_square = array_sum * array_sum

    # calcualting a1^2 + a2^2 + ... + an^2
    individual_square_sum = 0
    for i in range(0, n, 1):
        individual_square_sum += (A[i] * A[i])%mod

    # required sum is (array_sum_square -
    # individual_square_sum) / 2
    return (((array_sum_square -
            individual_square_sum))%mod / 2)%mod

ans = (int(findProductSum(a, n)))%mod
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
An = list(map(int, input().split()))
An_s = set(An)
total = sum(An_s)
ans = 0
for A in An_s:
    At = A * (total-A)
#     print(A, total, At, ans)
    ans = (ans+At) % (10**9+7)
#     print(ans)
print(ans//2)

Submission status: Wrong Answer

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

mod = 1000000007
ans = 0
A = 0
B = 0
for i in range(n):
    A += a[i]
    B += a[i] ** 2
    B %= mod
A %= mod
A2 = A**2 % mod
ans = (A2 - B) % mod
ans //= 2
print(ans)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())

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

q = collections.deque(a)

retu = sum(a)
ans = 0

for i in range(n):
    nowA = q.popleft()
    retu -= nowA
    ans += (nowA * retu)
    print(nowA,retu)

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
aa=0
p,S = 0,0
for i in range(N-1):
    AA = 0
    for j in range(i+1,N):
        AA += A[j]
    aa = A[i]*AA
    a = aa&1000000007
    S += a
p = S%1000000007
print(p)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

n = stdin.readline().rstrip().split()[0]
A = np.array([int(x) for x in stdin.readline().rstrip().split()])

print(int(((sum(A)**2 - np.dot(A,A)) / 2) % (10**9 + 7)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
ans=0
cnt=0
# while True: """
for i in range(n-1):
    for j in range(i+1, n):
        ans+= a[i]*a[j]
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import *
N = int(input())
A = list(map(int,input().split()))
ans = 0
a = combinations(range(N),2)
for i in a:
    ans += A[i[0]] * A[i[1]]

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

l = list(map(int,input().split()))
sum = 0
mo = 1000000007
for i in range(n):
    sum += l[i]
    sum %= mo

sum_square = ((sum%mo)**2)%mo
sum_2 = 0
l_1 = [(i*i)%mo for i in l]
for i in l_1:
    sum_2 += i
    sum_2 %= mo

t = (((sum_square - sum_2)%mo)//2)
print(t)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
M = 1000000007
sm = 0
for i in l:
	sm = (sm + i)
sms = pow(sm,2,M)
ss = 0
for i in range(n):	
	ss = (ss + (l[i] * l[i]))
print(((sms - ss)//2)%M)

Submission status: Wrong Answer

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

ans = 0
res = numpy.cumsum(A)
sum_A = sum(A)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
B = [0]*N

for i in range(N):
  A[i] = int(A[i])
  B[i] = A[i]*A[i]

print(int(( (sum(A)*sum(A)) - sum(B) ) % ( 10**9 + 7 ) / 2 ) )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

MOD = 1000000007

sum_all = 0
for i in range(len(a)):
    sum_all += a[i]
#sum_all %= MOD
sum = 0
#print(sum_all)
for i in range(len(a)):
    X = (sum_all - a[i])
    Y = a[i]
    sum += (X*Y/2)
    sum %= MOD
print(int(sum)%MOD)

Submission status: Wrong Answer

Solution code:
N=int(input())
A = [int(x) for x in input().split()]
S=[]
for i in range(N):
    s=sum(A[i+1:])*A[i]%(10**9+7)
    S.append(s)
print(sum(S))

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
t=np.array(input().split(' '))
num=np.zeros(n)
for a in range(n):
  num[a]=int(t[a])
a=np.sum(num)**2
b=np.sum(num**2)
x=(a-b)/2
x=x%(10**9+7)-1
print(int(x))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = input().split()
ai=np.array(a, dtype="int64")

div=(1E9+7)*2

#total=sum(ai)**2
#diagonal=sum(ai**2)
#ans=(total-diagonal)/2

totalmod=(sum(ai)%div)**2
diagonalmod=sum((ai**2)%div)
ansmod=totalmod-diagonalmod

if (ansmod <= 0):
  ansmod=ansmod+div

print(int((ansmod/2)%(1E9+7)))

Submission status: Wrong Answer

Solution code:
input()
lis = list(map(int,input().split()))
def sol(lis):
    s = sum(lis)
    r = 0
    sq = s*s
    for i in lis:
        r+=i**2
    print((sq-r)//2)
sol(lis)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def findProductSum(A, n):

    # calculating array sum (a1 + a2 ... + an)
    array_sum = 0
    for i in range(0, n, 1):
        array_sum = ((array_sum)%mod + A[i])%mod

    # calcualting square of array sum
    # (a1 + a2 + ... + an)^2
    array_sum_square = array_sum * array_sum

    # calcualting a1^2 + a2^2 + ... + an^2
    individual_square_sum = 0
    for i in range(0, n, 1):
        individual_square_sum += (A[i] * A[i])%mod

    # required sum is (array_sum_square -
    # individual_square_sum) / 2
    return ((array_sum_square -
            individual_square_sum))%mod / 2

ans = (int(findProductSum(a, n)))%mod
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import numpy as np

n = int(input())
A = [int(a) for a in input().strip().split()]
s = sum(A)
AA = np.array(A)
S = 0
mod = 2000000000+14
ss = sum(AA*AA)%mod
for a in A:
    S += (s*a)%mod
S = (S-ss)//2
print(S)

Submission status: Wrong Answer

Solution code:
N=int(input())
d=[int(s) for s in input().split()]
d_1=(sum(d))**2
d_2_pre=list(map(lambda x:x**2,d))
d_2_pre_int=[int(s) for s in d_2_pre]
d_2=sum(d_2_pre_int)
print(int((d_1-d_2)/2)%(10**9+7))

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]
s = s**2
for i in range(N):
  s -= a[i]*a[i]
s = s/2
while s >= 10**9 +7:
  s = s % (10**9 +7)
print(int(s))

Submission status: Wrong Answer

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

com_A = combinations(A,2)
ans = 0
MOD = 10**9 + 7
for x, y in com_A:
    ans = (ans + (x * y)) * MOD

print(ans)

Submission status: Wrong Answer

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

m = 1000000007

s = sum(a)
ans = 0
for i in range(n):
    aa = a[i]
    ans += aa * (s - aa)

ans = int(ans/2)
ans = ans % m

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = input()
a = l.split(' ')

tmp = 0
tmp2 = 0

for i in range(n):
    tmp += int(a[i])

for i in range(n):
    tmp2 += int(a[i])*int(a[i])

total = (tmp*tmp-tmp2)/2

print(int(total - 1000000007*(total//1000000007)))

Submission status: Wrong Answer

Solution code:
mod = 1000000007

def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    for i in range(N - 1):
        ans += (A[i] * sum(A[i + 1:]) / mod)
    print(ans % mod)

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

s = sum(a)
ans = 0

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

print(int(ans))

Submission status: Wrong Answer

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

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

print(total)

Submission status: Wrong Answer

Solution code:
MOD = 1000000007

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

array_sum = 0
for i in range(0, n, 1): 
    array_sum = (array_sum % MOD + a[i]%MOD)%MOD 

array_sum_square = (array_sum % MOD * array_sum %MOD)%MOD

individual_square_sum = 0
for i in range(0, n, 1): 
    individual_square_sum = (individual_square_sum%MOD +((a[i]%MOD * a[i]%MOD)%MOD)%MOD)%MOD

ans=(array_sum_square - individual_square_sum) / 2
print(int(ans%MOD))

Submission status: Wrong Answer

Solution code:
n=int(input())
inf=10**9+7
a=list(map(int,input().split()))
import numpy as np
arr_a=np.array(a)
s=np.sum(arr_a)
norm=np.sum(arr_a**2)
x=(s**2-norm)//2
print(x-(x//inf)*inf)

Submission status: Wrong Answer

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

b = 0
c = 0
for i in range(n):
  b += a[i]**2/2%m
  c += a[i]

d = c**2/2 -b
ans = int(d%m)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
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
sum = 0
for i in A:
    sum += i
sum %= mod    

ans = sum * sum
for j in A:
    ans -= j * j
    ans %= mod
ans //= 2    

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = 0
for i in a:
    sum += i

sum = sum * sum % 1000000007

for j in a:
    sum = (sum - j*j) % 1000000007

print(int(sum/2))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import numpy as np

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

MOD = 1.e9 + 7
val = 0

for i in range(0, N - 1):
    for j in range(i + 1, N):
        val += int(As[i] % MOD * As[j] % MOD) % MOD

print(int(val))

# print(val)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int,input().split())
ans = 0
ans2 = 0
mod = 10 ** 9 + 7
for a in A:
    ans += a
    ans2 += a**2
    ans %= mod 
    ans2 %= mod
print(((ans ** 2 + mod -ans2)%mod//2))

Submission status: Wrong Answer

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


def findProductSum(A, n):

    # calculating array sum (a1 + a2 ... + an)
    array_sum = 0
    for i in range(0, n, 1):
        array_sum = (array_sum)%mod + A[i]

    # calcualting square of array sum
    # (a1 + a2 + ... + an)^2
    array_sum_square = array_sum * array_sum

    # calcualting a1^2 + a2^2 + ... + an^2
    individual_square_sum = 0
    for i in range(0, n, 1):
        individual_square_sum += (A[i] * A[i])%mod

    # required sum is (array_sum_square -
    # individual_square_sum) / 2
    return ((array_sum_square -
            individual_square_sum))%mod // 2

ans = (int(findProductSum(a, n)))%mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np


def main():
    n = int(input().strip())
    l = list(map(int, input().split()))
    l = np.array(l)

    tot = 0
    for i in range(n):
        tot += l[i] * (np.sum(l[i + 1:n], dtype='int64')) % (10 ** 9 + 7)

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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(0, N):
            if i != j:
                ai = A[i]
                aj = A[j]
                if ai <= aj:
                    ans += ai * aj
                    if ans > mod_v:
                        ans = ans % mod_v
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
MOD = 1000000007

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

array_sum = 0
for i in range(0, n, 1): 
    array_sum = (array_sum % MOD + a[i]%MOD)%MOD 

array_sum_square = pow(array_sum,2,MOD)

individual_square_sum = 0
for i in range(0, n, 1): 
    individual_square_sum+= pow(a[i],2,MOD)
    individual_square_sum%MOD

ans=(array_sum_square - individual_square_sum+MOD) / 2
print(int(ans%MOD))

Submission status: Wrong Answer

Solution code:
def findProductSum(A, n): 
      
    # calculating array sum (a1 + a2 ... + an) 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = array_sum + A[i] 
  
    # calcualting square of array sum 
    # (a1 + a2 + ... + an)^2 
    array_sum_square = array_sum * array_sum 
  
    # calcualting a1^2 + a2^2 + ... + an^2 
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
  
    # required sum is (array_sum_square - 
    # individual_square_sum) / 2 
    temp=int(array_sum_square - 
            individual_square_sum) / 2
    return temp%1000000007








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

Submission status: Wrong Answer

Solution code:
mod = 1000000007
def findProductSum(A, n): 
    array_sum = 0
    for i in A: 
        array_sum = (array_sum + i)%mod
    array_sum_square = (array_sum * array_sum)%mod
    individual_square_sum = 0
    for i in A: 
        individual_square_sum = (individual_square_sum + (i * i)%mod)%mod
    tmp = (((array_sum_square - individual_square_sum)%mod) // 2)%mod
    return tmp
n = int(input())
lis = list(map(int,input().split()))
print(findProductSum(lis,n))

Submission status: Wrong Answer

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

ans = sum(nums)**2 - sum(map(lambda x: x**2, nums))

ans /= 2

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

Submission status: Wrong Answer

Solution code:


def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9+7
    norm = 0
    for a in A:
        norm += a**2
        # norm = norm%mod
    ans = ((sum(A))**2 - norm) / 2
    print(int(ans%mod))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
#437235829 mod(10^9+7)
sumAcol=0
sumA=0
sumtr=0
for i in range(N):
  sumtr+=A[i]**2
  sumAcol+=A[i]
sumAcol=sumAcol % (10**9+7)
for i in range(N):
  sumA+=sumAcol*A[i]
sumA=(sumA-sumtr)/2

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input().split(' ')
b=[]
for x in a:
    b.append(int(x))
su=0
for t in b:
    su+=t
    
su=su*su
pas=0
for t in b:
    pas+=t*t
er=su-pas
er/=2
print(int(int(er)%1000000007))

Submission status: Wrong Answer

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
mod=(10**9)+7
n=int(input())
a=list(map(int,input().strip().split(' ')))
s=0
for x in a:
	s= (s+x)%mod
s=(s**2)%mod
t=0
for x in a:
	t= (t+ x**2)%mod
ans=((((s-t)%mod+mod)%mod)//2)
print(ans%mod)

Submission status: Wrong Answer

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

#1
sum_A = sum(A)
#2
B = sum_A*sum_A
#3
C = 0
for i in range(N):
  C = C + A[i]*A[i]
  
#4
res = int((B-C)/2)

#5
ans = res % (10**9+7)

print(ans)

Submission status: Wrong Answer

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

size = len(ls)

ans = 0
for i in range(size - 1):
  gou = sum(ls[i+1:size])
  ans = ans + (gou * i)

print(ans % 100000007)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(float, input().split()))
S = sum(A)
result = 0
mod = 10 ** 9 + 7
for a in A:
  S -= a
  result += a * S
result %= mod
print("{:.0f}".format(result))

Submission status: Wrong Answer

Solution code:
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N = int(input())
A = input().split()

Sum = 0

for i in range(N):
    Sum += int(A[i])

ans = 0
for i in range(N):
    ans += (int(A[i])%1000000007*(Sum-int(A[i]))%1000000007)%1000000007
    ans %= 1000000007

print(int(ans%1000000007/2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
M = 1000000007
sm = 0
for i in l:
	sm = (sm + i)
sms = pow(sm,2,M)
ss = 0
for i in range(n):	
	ss = (ss + (l[i] * l[i]))
print(sms,ss)
print(((sms - ss)//2)%M)

Submission status: Wrong Answer

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

for i in itertools.combinations(a,2):
    if i[0]==i[1]:
        continue
    else:
        s+=i[0]*i[1]

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

Submission status: Wrong Answer

Solution code:
import math
import collections
import itertools

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

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

    print(ans)

resolve()

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input().split())
A=[int(n) for n in S]
ans=int(0)
count=0
for i in A:
    count +=1
    del A[0:count]
    for j in A:
        ans += i*j
print(ans)

Submission status: Wrong Answer

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

bigNum = 10 ** 9 + 7
rets = [0]

def bt(track, start):
    if len(track) == 2:
        rets[0] += (track[0] * track[1]) % bigNum
        return

    for i in range(start, len(A)):
        track.append(A[i])
        bt(track, i + 1)
        track.pop()
tr = []
bt(tr, 0)
print(rets[0])

Submission status: Wrong Answer

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

mod = 1000000007
ans = 0
A = 0
B = 0
for i in range(n):
    A += a[i]
    B += a[i] ** 2
    B %= mod
A2 = A**2 % mod
ans = (A2 - B) % mod
ans /= 2
print(int(ans))

Submission status: Wrong Answer

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


def findProductSum(A, n):

    # calculating array sum (a1 + a2 ... + an)
    array_sum = 0
    for i in range(0, n, 1):
        array_sum = array_sum + A[i]

    # calcualting square of array sum
    # (a1 + a2 + ... + an)^2
    array_sum_square = array_sum * array_sum

    # calcualting a1^2 + a2^2 + ... + an^2
    individual_square_sum = 0
    for i in range(0, n, 1):
        individual_square_sum += A[i] * A[i]

    # required sum is (array_sum_square -
    # individual_square_sum) / 2
    return ((array_sum_square -
            individual_square_sum))%mod // 2

ans = (int(findProductSum(a, n)))%mod
print(ans)