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())
a = list(map(int, input().split()))

sum = 0
for i in range(n):
    sum += a[i]

res = 0
for i in range(n):
    res = (res + (sum - a[i]) * a[i] / 2) % (10**9 + 7)
print(int(res))

Submission status: Wrong Answer

Solution code:
def calc(A, N, i):
    ans = 0
    for i in range(i, N - 1):
        ai = A[i]
        aj = A[i + 1]
        ans += ai * aj
    return (ans)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod_v = 10**9 + 7
    ans = [0] * (N + 1)
    for i in range(0, N - 1):
        if A[i] != 0:
            ans[i] = calc(A, N, i)
            break
    for j in range(i + 1, N - 1):
        if A[j - 1] != 0 and ans[j] == 0:
            ans[j] = (ans[j - 1] - A[j - 1] * A[j]) // A[j - 1] * A[j]
        else:
            ans[j] = 0
    ret = 0
    for k in range(0, N):
        ret += ans[k]
    ret = ret % mod_v
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

print(list1)  
for i in range(N-1):
    for j in range(i+1,N):
        
        sum = sum + list1[i]*list1[j]
answer = divmod(sum, 10**9+7)
print(answer[1])

Submission status: Wrong Answer

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

for a in A:
    tmp -= a
    sum_ += a * tmp

print(sum_)

Submission status: Wrong Answer

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

sum_of_power = (sum(A) ** 2) % 1000000007
power_of_sum = (sum([a ** 2 for a in A])) % 1000000007

ans = sum_of_power - power_of_sum

if ans < 0:
    ans += 1000000007

ans //= 2

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin

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

s = str(int((sum(A)**2 - sum([a**2 for a in A])) / 2))

if(int(s) < (10**9 + 7)):
    print(int(s))
else:
    x = int(s[-9:]) - 7 * int(s[:-9])
    if(x < 0):
        print(x % (10**9 + 7))
    else:
        print(x)

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 = int((tmp*tmp-tmp2)/2)

print(int(((tmp*tmp-tmp2)/2)%1000000007))

Submission status: Wrong Answer

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

print(sum(a * (tmp - a) for a in A))

Submission status: Wrong Answer

Solution code:
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
l = LI()
ans = 0

for i in range(n-1):
    # print("i:{} n-1:{} n-i:{}".format(i,n-1,n-i))
    j = i + 1
    while j <= n-1:
        buf = (l[i]%mod) * (l[j]%mod)# % mod
        ans = ans + buf
        # print("l[i]: {}, l[j]: {}, buf:{}".format(l[i],l[j],buf))
        j += 1
print(ans)# % mod)

Submission status: Wrong Answer

Solution code:
import itertools
MOD = 1000000007

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

answer = 0
comb_list = list(itertools.combinations(A, 2))
for c in comb_list :
    answer += (int(c[0]) * int(c[1])) % MOD
print (answer )

Submission status: Wrong Answer

Solution code:
num = int(input())
a = list(map(int, input().split()))
mod = 1000000007
s = ((sum(a) % mod) * (sum(a) % mod)) % mod

indi = 0
for i in a:
  indi += ((i % mod) * (i % mod)) % mod

print((s - indi) / 2)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N = int(input())
A = list(map(int, input().split()))

mod = 10 ** 9 + 7

s = ((sum(A) % mod) ** 2) % mod



a = 0
for i in A:
    a += (i ** 2) % mod
    a = a % mod
if s - a < 0:
    s += 10**9 + 7
ans = (s - a) // 2

print(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%1000000007+ A[i]%1000000007)%1000000007

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

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

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

n = int(input())
arr = input()   # takes the whole line of n numbers
l = list(map(int,arr.split(' ')))


print(((int)(findProductSum(l,n)))%1000000007)

Submission status: Wrong Answer

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

mod = 10**9+7

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

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

tri = (all-di)//2

print(tri % mod)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
mod = 1000000007
sum = 0
indsum = 0
for i in A:
  sum += i
  sum%=mod
  p = (i*i)%mod
  indsum+=p
  indsum%=mod
squaresum = (sum*sum)%mod
res = (((squaresum-indsum)%mod)//2)%mod
print(res)

Submission status: Wrong Answer

Solution code:
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
l = LI()
ans = 0

for i in range(n-1):
    # print("i:{} n-1:{} n-i:{}".format(i,n-1,n-i))
    j = i + 1
    while j <= n-1:
        buf = (l[i]%mod * l[j]%mod)# % mod
        ans = ans + buf
        # print("l[i]: {}, l[j]: {}, buf:{}".format(l[i],l[j],buf))
        j += 1
print(ans)# % mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
 
n = int(input())
a = input().split()
ai=np.array(a, dtype="int64")
 
div=1000000007
 
totalmod=(sum(ai)%div)**2
totalsho=(sum(ai)//div)
if (totalsho%2 == 1): totalmod=totalmod+div

diamod=0
for i in range(0,n):
  diagonalmod=(ai[i]**2)%div
  diagonalsho=(ai[i]**2)//div
  if (diagonalsho%2 == 1): diagonalmod=diagonalmod+div
  diamod=diamod+diagonalmod

ansmod=(totalmod-diamod)/2+div*10000000000
#if (ansmod <=0):
#  kake=(-ansmod)//div+100
#  ansmod=ansmod+kake*div
  
print(int((ansmod)%div))

Submission status: Wrong Answer

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

mod = 10**9 + 7
x = int(sum(A) / 2)**2 * 2 % mod
y = (x - sum([a**2 / 2 % mod for a in A]))
print(int(y) % mod)

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())

xlist = input().split(" ")
ylist = []

for num in xlist:
    ylist.append(int(num))


    """
pairs = itertools.combinations(ylist, 2)
answer = 0
for pair in pairs:
    answer += pair[0] * pair[1]

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


def findProductSum(A, n):
    product = 0
    for i in range(n):
        for j in range(i + 1, n):
            product = product + A[i] * A[j]
    return product


print(findProductSum(ylist,N ))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools
x = 10**9 + 7
n = int(input())
a = list(map(lambda i: i % x , map(int, input().split(" "))))

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

B = np.array(A)

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

dot = np.dot(B,B.T)
print((dot - a)/2)

Submission status: Wrong Answer

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

print(list1)  
for i in range(N-1):
    for j in range(i+1,N):
        
        sum = sum + list1[i]*list1[j]
answer = divmod(sum, 10**9+7)
print(answer[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = 0
for i in range(n):
    sum += a[i]

res = 0
for i in range(n):
    res = res + (sum - a[i]) * a[i]
print(int(res% (10**9 + 7)/2))

Submission status: Wrong Answer

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

total = 0

for j in range(2,n+1):
    aa = 0
    for i in range(1,j):
        aa += a[i-1] * (i-1)
    total += aa * a[j-1]


    
    

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

Submission status: Wrong Answer

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

MOD = 10**9 + 7
s = 0
for i in a:s+=i

ans = 0
for i in a:
    ans += (((i*s)-(i*i)))
ans = ans/2
print(int(ans%MOD))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N = int(input())
A = list(map(int, input().split()))

mod = 10 ** 9 + 7

s = ((sum(A) % mod) ** 2) % mod



a = 0
for i in A:
    a += (i ** 2) % mod
    a = a % mod
if s - a < 0:
    s += 10**9 + 7
ans = (s - a) // 2
if ans < 0:
    ans += 10 ** 9 + 7
else:
    ans = ans % mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split(" ")))
mod_num = 1e9 + 7

sum_lst = sum(A)

sum_tmp = 0
for i in range(N-1):
    sum_tmp += (((sum_lst - A[i])%mod_num)*(A[i]))%mod_num
    sum_lst = sum_lst - A[i]

print(int(sum_tmp%mod_num))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n=int(input())
alist=list(map(int,input().split()))
blist=sorted(alist)
sumlist=[0]*n
p=10**9+7
for i in range(n):
  c=blist[i+1:]
  j=sum(c)
  sumlist[i]=j%p
sumk=0
for i in range(n):
  k=blist[i]*sumlist[i]
  sumk+=k%p
print(sumk)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(e) for e in input().split()]
sum = 0
for i in A :
    for j in A:
        if i == j : continue
        sum = sum + i*j
print(sum%1000000007)

Submission status: Wrong Answer

Solution code:
import numpy as np
 
n = int(input())
a = input().split()
ai=np.array(a, dtype="int64")
 
div=1000000007
 
totalmod=(sum(ai)%div)**2
totalsho=(sum(ai)//div)
if (totalsho%2 == 1): totalmod=totalmod+div

diamod=0
for i in range(0,n):
  diagonalmod=(ai[i]**2)%div
  diagonalsho=(ai[i]**2)//div
  if (diagonalsho%2 == 1): diagonalmod=diagonalmod+div
  diamod=diamod+diagonalmod

ansmod=(totalmod-diamod)/2+div*100000
#if (ansmod <=0):
#  kake=(-ansmod)//div+100
#  ansmod=ansmod+kake*div
  
print(int((ansmod)%div))

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
import math
import collections
import copy
import decimal
from collections import deque 
from functools import reduce
from itertools import product
from itertools import combinations

N = int(input())
An = list(map(int, input().split()))
An_s = collections.Counter(An)
total = 0
for k in An_s:
    total += k
tt = sum(An)
ans = 0
for A, v in An_s.items():
    At = A * (tt-A*v)*v
#     if v == 1:
#         At = A * (tt-A)
#     else:
#         At = A * (tt-A*v)*v
#     print(A, v, total, At, ans)
    md = At % (10**9+7)
    ans = (ans+md) % (10**9+7)
#     print(ans)




print(ans//2)

Submission status: Wrong Answer

Solution code:
num = int(input())
a = list(map(int, input().split()))
mod = 1000000007
s = ((sum(a) % mod) * (sum(a) % mod)) % mod

indi = 0
for i in a:
  indi += ((i % mod) * (i % mod)) % mod

print((((s % mod) - (indi % mod)) % mod) / 2)

Submission status: Wrong Answer

Solution code:
N = int(input())
Lists = list(map(int, input().split()))
Lists2 = []
for i in Lists:
    Lists2.append(i%(10**9+7))
cnt = 0
for i in range(N-1):
    j = i + 1
    for s in range(j, N):
        cnt = cnt + (Lists2[i] * Lists2[s])%(10**9+7)


print(cnt)

Submission status: Wrong Answer

Solution code:
import functools
import operator

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N=int(input())
X=list(map(int,input().split()))
S=0
for i in range(N-1):
    for j in range(N-i-1):
        S=S+X[i]*X[i+1+j]
print(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])
x=0
for a in range(n-1):
  x+=num[a+1]*np.sum(num[0:a+1])
x=x%(10**9+7)
print(int(x))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
l = LI()
ans = 0

for i in range(n-1):
    # print("i:{} n-1:{} n-i:{}".format(i,n-1,n-i))
    j = i + 1
    while j <= n-1:
        buf = (l[i] * l[j]) % mod
        ans = ans + buf
        # print("l[i]: {}, l[j]: {}, buf:{}".format(l[i],l[j],buf))
        j += 1

print(ans)

Submission status: Wrong Answer

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

n = int(input().rstrip())
a_row = list(map(int, input().rstrip().split()))

a = np.array(a_row)
MOD = 1000000007
ans = 0

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

# region fastio
# Credits
# # template credits to cheran-senthil's github Repo

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


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

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

# endregion

def main():
    mod = 1000000007
    def findProductSum(A, n): 
        array_sum = 0
        for i in A: 
            array_sum = (array_sum + i)%mod
        array_sum_square = pow(array_sum,2,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))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
i = 0
tmp = 0
tmpura = 0
while(i < n):
    tmp += a[i]
    i+=1
tmp=tmp **2
i = 0
while (i < n):
    tmpura += a[i]**2
    i+=1
tmpura=tmpura
ans = ((tmp - tmpura)/2)%(10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x)%(1e9+7) for x in input().split()]
partial_sum = A.copy()
sum_now = A[N-1]
for j in range(N-2,-1,-1):
    sum_now = int((sum_now+A[j])%(1e9+7))
    partial_sum[j] = sum_now
res = 0
for i in range(N-1):
    res = (res + (A[i]*partial_sum[i+1]) %(1e9+7)) %(1e9+7)
print(int(res%(1e9+7)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

MOD = 10**9 + 7
s = 0
for i in a:s+=i

ans = 0
for i in a:
    ans += (((i*s)-(i*i))/2)

print(int(ans%MOD))

Submission status: Wrong Answer

Solution code:
def findProductSum(A,n): 
    product = 0
    for i in range (n): 
        for j in range ( i+1,n): 
            product = product + A[i]*A[j] 
    return product 
   
n = input()
n = int(n)
A = list(map(int, input().split()))     
print(findProductSum(A, n))

Submission status: Wrong Answer

Solution code:
def findProductSum(A, n): 
    array_sum = 0
    individual_square_sum = 0
    for i in range(0, n): 
        array_sum = array_sum + A[i] 
        individual_square_sum += A[i] * A[i] 
  
    array_sum_square = array_sum * array_sum 
    return (array_sum_square - individual_square_sum) / 2
  
if __name__ == '__main__': 
    n = int(input())
    A = list(map(int, input().split()))
    print(int(findProductSum(A, n)%1000000007))

Submission status: Wrong Answer

Solution code:
import numpy as np
 
n = int(input())
a = input().split()
ai=np.array(a, dtype="int64")
 
div=1000000007
 
totalmod=(sum(ai)%div)**2
totalsho=(sum(ai)//div)
if (totalsho%2 == 1): totalmod=totalmod+div

diamod=0
for i in range(0,n):
  diagonalmod=(ai[i]**2)%div
  diagonalsho=(ai[i]**2)//div
  if (diagonalsho%2 == 1): diagonalmod=diagonalmod+div
  diamod=diamod+diagonalmod

ansmod=(totalmod-diamod)/2
if (ansmod <=0):
  kake=(-ansmod)//div+1
  ansmod=ansmod+kake*div
  
print(int((ansmod)%div))

Submission status: Wrong Answer

Solution code:
def solve():
  N = int(input())
  AA = list(map(int,input().split()))
 
  ans = 0
  for a in AA:
    ans += a
  ans = ans % (10**9+7)
  ans = ans**2
  for a in AA:
    ans -= a**2
    if ans<0:
      ans = (ans +(10**9+7)**2)%(10**9+7)
  ans = ans % (10**9+7)
  while ans<0:
    ans += 10**9+7
  print(int(ans/2))
solve()

Submission status: Wrong Answer

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

MOD = 1000000007
ans=0
for i in range(2**N):
    bin_str = format(i, 'b')
    bin_ = bin_str.count('1')
    if 1 < bin_ < N:
        if bin_ == 2:
            temp=1
            for n in range(N):
                if i>>n&1:
                    temp *=A[n-1]%MOD
            ans+=temp

print(ans)

Submission status: Wrong Answer

Solution code:
MOD=1000000007
N=input()
A = [int(x)%MOD for x in input().split()]
l=len(A)
s=0
for i in range(l):
    for j in range(i+1,l):
        s+=A[i]*A[j]
print(s)

Submission status: Wrong Answer

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

MOD = 10**9 + 7
s = 0
for i in a:s+=i

ans = []
for i in a:
    ans.append(((i*s)-(i*i))/2)

pans = 0

for i in ans:
    pans+=i
    pans = pans % MOD
print(pans)

Submission status: Wrong Answer

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

mod = 10**9 + 7
x = int(sum(A)**2 / 2 % mod)
y = (x - int(sum([a**2 / 2 % mod for a in A])))
print(int(y) % mod)

Submission status: Wrong Answer

Solution code:
#C - Sum of product of pairs
N = int(input())
A = list(map(int,input().split()))
ans = 0
P = 0
E = 0
for i in range(N):
    P += (A[i]%(10**9+7))**2
    E += A[i]%(10**9+7)

ans =int(((E**2 - P)/2)%(10**9+7))
print(ans)

Submission status: Wrong Answer

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


Sum = 0
mod_n = 10.0E8 +7

for i in range(N-1):
    for j in range(i+1,N):
        if j == len(A):
            break
        else:
            Sum +=  A[i]*A[j]
        


# for i in A:
#     Sum -= i**2

# Sum = int(Sum/2)
print(Sum)


print(int(Sum % mod_n))

Submission status: Wrong Answer

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

MOD = 10**9+7

ans = 0
for i in range(N-2):
  t =  A[i] * (A[i+1] + A[-1]) * (N - i - 1) // 2
  # print(t)
  ans += t % MOD

t = A[-2] * A[-1]
# print(t)
ans += t % MOD

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
k = 0
num = sum(a)
import math

for i in range(n):
    k = k + (a[i] * num) - (a[i] ** 2)

x = math.floor(k / 2)
t = 1000000000 + 7
ans = x % t
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    mod = 10 ** 9 + 7
    s = 0
    q = 0
    for a in A:
        s += a % mod
        q += a ** 2 % mod
        s %= mod
        q %= mod
    ans = (((s * s) % mod - q) % mod) // 2
    print(int(ans % mod))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import decimal


def resolve():
    n = int(input())
    A = list(map(lambda x: decimal.Decimal(x) % (10**9 + 7), input().split()))
    A_sum = sum(A)
    ind_sum = 0
    for a in A:
        ind_sum += a**2

    print((A_sum**2 - ind_sum)/2 % (10**9 + 7))

resolve()

Submission status: Wrong Answer

Solution code:
def sum_of_product_of_pair():
    n = int(input())
    A = [int(num) for num in input().split(" ", n-1)]

    product = 0
    for i in range (n): 
        for j in range ( i+1,n): 
            product = product + A[i]*A[j] 
    print(product)

sum_of_product_of_pair()

Submission status: Wrong Answer

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

mod = 10**9 + 7
x = sum(A)**2 % mod
y = (x / 2 - sum([a**2 / 2 % mod for a in A]))
print(int(y) % mod)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n=int(input())
alist=list(map(int,input().split()))
blist=sorted(alist)
sumlist=[0]*n
p=10**9+7
for i in range(n):
  j=0
  for val in range(i+1,n):
    j+=blist[val]
  sumlist[i]=j%p
sumk=0
for i in range(n):
  k=blist[i]*sumlist[i]
  sumk+=k%p
print(sumk)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve():
  N = int(input())
  AA = list(map(int,input().split()))
 
  ans = 0
  for a in AA:
    ans += a
  ans = ans % (10**9+7)
  ans = ans**2
  for a in AA:
    ans -= a**2
    if ans<0:
      ans += 10**9+7
  ans = ans % (10**9+7)
  while ans<0:
    ans += 10**9+7
  print(int(ans/2))
solve()

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])
x=0
for a in range(n-1):
  x+=num[a+1]*np.sum(num[0:a+1])
x=x%((10**9)+7)
print(int(x))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
ans = 0
for i in A:
    for j in A:
        ans += (i*j) % (10**9+7)
mi = sum([x ** 2 for x in A])
ans -= mi
ans = ans % (10**9+7)
print(int(ans/2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().rstrip().split(" ")

l = []
for i in range(n):
    l.append(int(a[i]))

x = 0
MOD = 1000000007
for i in range(n - 1):
    for j in range(i + 1, n):
        x += l[i] % MOD * l[j] % MOD
#        print(str(l[i]) + " * " + str(l[j]))
print(x)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

# i = j
ij = np.sum(A_array * A_array)

Acum = np.sum(A_array)

temp = 0
for i in A:
    temp += (i*Acum - i**2) % ((10**9 + 7)*2)

print(int(temp/2) % (10**9 + 7))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split(" ")))
mod_num = 1e9 + 7

sum_lst = sum(A)

sum_tmp = 0
for i in range(N):
    sum_tmp += (((sum_lst - A[i])%mod_num)*(A[i]))%mod_num
    sum_lst = sum_lst - A[i]

print(int(sum_tmp%mod_num))

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    mod = 10 ** 9 + 7
    s = 0
    q = 0
    for a in A:
        s += a % mod
        q += a ** 2 % mod
        s %= mod
        q %= mod
    ans = (((s * s) % mod - q) % mod) / 2
    print(int(ans % mod))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def solve():
  N = int(input())
  AA = list(map(int,input().split()))
 
  ans = 0
  for a in AA:
    ans += a
  ans = ans % (10**9+7)
  ans = ans**2
  for a in AA:
    ans -= a**2
  ans = ans % (10**9+7)
  while ans<0:
    ans += 10**9+7
  print(int(ans/2))
solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
a=list(map(int, input().split()))
a=np.array(a)
b=a**2
mod=10**9+7
ans=np.sum(a)**2
l=np.sum(b)
print((ans-l)//2%mod)

Submission status: Wrong Answer

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

ans = 0
my_sum = sum(lst1)
fi= my_sum**2
for i in range(n):
    ans += lst1[i]**2

res = (my_sum-fi)//2
print(res % ((10**9)+7))

Submission status: Wrong Answer

Solution code:
def solve():
  N = int(input())
  AA = list(map(int,input().split()))
 
  ans = 0
  for a in AA:
    ans += a
  ans = ans % (10**9+7)
  ans = ans**2
  for a in AA:
    ans -= a**2
  ans = ans % (10**9+7)
  if ans<0:
    ans += 10**9+7
  print(int(ans/2))
solve()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
Amap=map(lambda x:x%1000000007,A)
def selfmult(x):
    return (x%1000000007)**2
dot=((sum(Amap)%1000000007)**2-sum(map(selfmult,A)))/2
print(int(dot)%1000000007)

Submission status: Wrong Answer

Solution code:
from numba import jit

def f(i, j):
  mod_n = 10 ** 9 +7
  return (i*j)% mod_n

@jit
def sigma(func, frm, to, list):
  result = 0
  for i, l in enumerate(list):
    for j in range(i+1, to):
      result += func(l, list[j])
  return result

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

print(sigma(f,0,N, A))