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:
from functools import lru_cache
from collections import Counter
mod=10**9+7

def main():
    n=int(input())
    a=Counter(map(int,input().split()))
    tt=tuple(a.items())
    if 0 in a.keys():
        del a[0]
    ans=0
    for v,s in a.items():
        ans += calc(v, tt)*s%mod
    print(ans%mod)

@lru_cache(maxsize=None)
def calc(x, l):
    ans = 0
    for v,s in l:
        if v >= x:
            continue
        ans += x*v*s%mod
    return ans

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.asarray(input().split()).astype(np.int)
A_sq = np.square(A)
Ans = np.mod(((A.sum())**2 - A_sq.sum()) / 2 ,(10**9+7)).astype(np.int)
print(Ans)

Submission status: Wrong Answer

Solution code:
# cook your dish here
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 
    if array_sum_square - individual_square_sum < 0 :
        return ((array_sum_square - individual_square_sum + 1000000007) / 2)%1000000007
    else :
        return ((array_sum_square - individual_square_sum) / 2)%1000000007
            
if __name__ == '__main__': 
    
    n = int(input())
    A = list(map(int,input().split())) 
    print(int(findProductSum(A, n))%1000000007)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
sum = 0
# temp1 = 0
# temp2 = 0
MOD = 1000000007
for i in range(0, N-1):
    A[i] = A[i] % MOD
print(A)
for i in range(0, N-1):
    for j in range(i+1, N):
        #print(i, j)
        temp1 = 0
        temp2 = 0
        temp3 = 0
        # temp1 = A[i] % MOD
        # temp2 = A[j] % MOD
        # temp3 = temp1 * temp2
        temp3 = (A[i] * A[j]) % MOD
        sum = (sum + temp3) % MOD
#sum = sum % MOD
print(sum)

Submission status: Wrong Answer

Solution code:
import sys
import array
import numpy as np

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

result = (B.sum()**2 - B.dot(B)) / 2
print(int(result%(10**9+7)))

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 main():
    n=int(input())
    a=list(map(int,input().split(" ")))
    totsum=(sum(a)%mod*sum(a)%mod)%mod
    prosum=0
    for x in a:
        prosum+=(x*x)%mod
    print((totsum-prosum)//2)
    


#-----------------------------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:
n = int(input())
a = list(map(int, input().split()))
c = 10 ** 9 + 7

ans = 0
tmp_val = 0
for i in range(n):
  tmp_val = (tmp_val + a[i]) % c

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

print(ans)

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)
    if temp >= 20**9 + 14:
        temp -= (20**9 + 14)

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

Submission status: Wrong Answer

Solution code:
mod = 1e9 +7
n = int(input())
a = list(map(int,input().split()))
pref=[0 for x in range(n)]
pref[0] = a[0]
for i in range(1,n):
    pref[i] += (pref[i-1]+a[i])
ans=0
for i in range(n-1,0,-1):
    ans += a[i]*pref[i-1]
    ans %= mod
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
import array
import numpy as np

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

result = (B.sum()**2 - B.dot(B)) / 2
print(int(result)%(10**9+7))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A_sum = sum(A[1:])

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

Submission status: Wrong Answer

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

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
y = (x - sum([a**2 for a in A])) / 2
print(int(y) % mod)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a = list(map(int,input().split()))[:n]
b = list()
for i in range(n):
    for j in range(i+1, n):
        pro=a[i]*a[j]
        b.append(pro)
sum=0
for i in b:
    sum += i
print(sum)

Submission status: Wrong Answer

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

p = list(itertools.combinations(A, 2))
emp = []
for v in p:
    a = np.prod(v)
    emp.append(a)
print(sum(emp))

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=int((a-b)/2)
if x<10**9+7:
  print(x)
else:
  x=x%(10**9+7)
  x-=1
  print(x)

Submission status: Wrong Answer

Solution code:
# cook your dish here
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 
    if array_sum_square - individual_square_sum < 0 :
        return (array_sum_square - individual_square_sum + 1000000007) / 2
    else :
        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:
def findProductSum(A, n): 
    s = 0
    for i in range(n): 
        s = s + A[i] 
    array_sum_square = s * s 
    individual_square_sum = 0
    for i in range(n): 
        individual_square_sum += A[i] * A[i] 
    return (array_sum_square -individual_square_sum) / 2
n=int(input())
a=list(map(int,input().split()))
print(findProductSum(a,n))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

x = 0
for i in range(len(l) - 1):
    for t in range(i + 1, len(l)):
        print(i, t)
        x += l[i]*l[t]

y = x % (10**9 + 7)
print(y)

Submission status: Wrong Answer

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

number = 0
MOD = 1000000007

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


if number > MOD:
    print(number%MOD)
else:
    print(number)

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.asarray(input().split()).astype(np.int)
A_sq = np.square(A)
Ans = ((A.sum())**2 - A_sq.sum()) // 2 % (10**9+7)
print(Ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
# = str(input())
# = map(int, input().split())
A = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

A = np.asarray(A)
total = sum(A)**2
doubleA = A**2

minustotal = sum(doubleA)

print((total-minustotal)//2%(10**9+7))

Submission status: Wrong Answer

Solution code:
def fastSumPair(A):
    L = len(A)
    M = 1000000007
    
    # (a + b + c)**2 = a**2 + b**2 + c**2 + 2*(a*b + b*c + c*a)
    # derive from this equation
    
    # first array
    A_1_sum = 0
    for i in range(0, L):
        A_1_sum = (A_1_sum + A[i]) % M
    
    A_1_sum = (A_1_sum ** 2) 
        
    # second array
    A_2_sum = 0
    for i in range(0, L):
        A_2_sum = (A_2_sum + A[i] ** 2) 
                  
    return int((A_1_sum - A_2_sum) / 2) % M

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

div=1000000007

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

print(ans%div)

Submission status: Wrong Answer

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

for i in range(len(A)):
    for j in range(i+1,len(A)):
        
        SUM = SUM+( A[i] * A[j])
        
print(SUM)

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)/2
    if temp >= 10**9 + 7:
        temp -= (10**9 + 7)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A= list(map(int,input().split()))
mod_num = 1.0e+9 + 7
rest = 0
temp = 0

for i in range(N-1):
  temp+=A[i]
  rest += temp*A[i+1]
  rest = rest%mod_num

print(int(rest%mod_num))

Submission status: Wrong Answer

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

print(res%m)

Submission status: Wrong Answer

Solution code:
from itertools import permutations, combinations,combinations_with_replacement,product
N = int(input())
add = 10**9+7
Z = list(map(int, input().split()))
mod = 10**9+7
com = combinations(Z,2)
for i , z in com:
  tt = i*z%add
  add = add + tt
res = add%(10**9+7)
print(res)

Submission status: Wrong Answer

Solution code:
def factorial( n) :
    M = 1000000007
    f = 1
 
    for i in range(1, n + 1): 
        f = f * i # WRONG APPROACH as 
                  # f may exceed (2^64 - 1) 
 
    return f % M

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
A = [0]*(n)
num = 1e9+7
ans = 0
for i in range(1, n):
    A[i] = A[i-1] + a[i-1]
for i in range(n-1, 0, -1):
    ans += (A[i]*a[i])%num
    ans %= num
ans %= num
print(int(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
a.sort(reverse=True)
M = 10**9 + 7
while True:
    fast = a.pop(0)
    for i in range(len(a)):
        print(fast,str(a[i]))
        ans += (fast * a[i])
    if len(a) == 1:
        break
print(ans%M)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

Submission status: Wrong Answer

Solution code:
def add(A):
    n=len(A)
    array_sum = 0
    for i in range(0, n, 1): 
        A[i]=int(A[i])
        array_sum = array_sum + A[i]
    array_sum_square = array_sum * array_sum
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i]
    return (array_sum_square - 
            individual_square_sum) / 2
x=int(input())
num=input().split()
answer=add(num)
print(int(answer)%1000000007)

Submission status: Wrong Answer

Solution code:
# cook your dish here
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) / 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:
n = int(input())
l = list(map(int, input().split()))
total = 0
for i in range(n-1):
  for j in range(i+1, n):
    total += l[i] * l[j]
print(total)

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy

N = int(input())
h = list(map(int, input().split()))
h.sort(reverse=True)
h2 = copy.copy(h)
ans = 0
s = np.sum(h2)
for i in range(N-1):
    s -= h[i]
    ans += h[i] * s
    if ans != 0:
        ans = ans % (10 ** 9 + 7)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = input()
a = list(map(int, input().split()))
#len_a = len(a)
#range_a = range(len_a)
times1 = []
times2 = []

for i, v in enumerate(a):
    times1.append(v)
    times2.append(sum(a[i + 1 : ]))

result = np.array(times1, dtype = "uint64") * np.array(times2, dtype = "uint64")

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

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)

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

print(int(ans%div))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
alist = list(map(int, input().split()))
import numpy as np
Sum_a = 0
Sum_j_list = np.cumsum(alist)
for i in range(N-1):
  Sum_j = Sum_j_list[N-1] - Sum_j_list[i]
  Sum_a += int((alist[i] * Sum_j) % int(1e9+7))
print(int(Sum_a % int(1e9+7)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
x = 0
z = 0
MOD = 10**9 + 7
for i in A:
  x = (x%MOD + i%MOD)%MOD
  z = (z%MOD + i*i%MOD)%MOD
y = x*x%MOD
print((y-z)//2)

Submission status: Wrong Answer

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

p = itertools.combinations(A, 2)
emp = []
for v in p:
    a = np.prod(v)
    emp.append(a)
print(sum(emp))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

A_sum = sum(A)
A_squared = sum([num**2 for num in A])

ans = (A_sum**2 - A_squared)/2
ans = int(ans%mod)
print(ans)

Submission status: Wrong Answer

Solution code:
n,*l=map(int,open(0).read().split())
print((sum(l)**2-sum(i**2 for i in l)//2)%(10**9+7))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
result = 0
i = 0
for x in A[:N]:
  for y in A[i+1:]:
    result += x * y
  i += 1

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

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]*A[i]
m=sum(A)
k=(m*m-s)/2
print(int(k%(10**9+7)))

Submission status: Wrong Answer

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

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

A_sum = sum(A)
A_squared = sum([num**2 for num in A])

ans = (A_sum**2 - A_squared)/2
ans = int(ans%mod)
print(ans-1)

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():
    if v == 1:
        At = A * (tt-A)
    else:
        At = A * (total-A)*v
#     print(A, v, total, At, ans)
    ans = (ans+At) % (10**9+7)
#     print(ans)
print(ans//2)

Submission status: Wrong Answer

Solution code:
n=int(input())
x = [int(i) for i in input().split()]
s1=0
s2=0
for i in range (0,n):
  s1=s1+x[i]
  s2=s2+x[i]**2
s1=s1**2
ans=(s1-s2)/2
print(int(ans%1000000007))

Submission status: Wrong Answer

Solution code:
n = int(input())
M = 1000000007
a = input().split()
sum = 0
sq_sum = 0
for x in a:
    y = int(x)
    sum += y
    sq_sum += (y*y)
sum = sum * sum
ans = abs(sum - sq_sum)/2
ans = (ans + M) % M
ans = int(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = 10**9+7
sa = sum(a)
c=0
for i in a:
    c +=i*i

print(int(((sa**2-c)/2)%b))

Submission status: Wrong Answer

Solution code:
n=int(input())
x = [int(i) for i in input().split()]
s1=0
s2=0
for i in range (0,n):
  s1=s1+x[i]
  s2=s2+x[i]**2
s1=s1**2
ans=(s1-s2)/2
print(ans%1000000007)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
import itertools
aha=list(itertools.combinations(a,2))
kotae=0
for i in range(len(aha)):
    print(aha[i])
    seki=aha[i][0]*aha[i][1]
    #print(seki)
    kotae+=seki
kotae=kotae%1000000007
print(kotae)

Submission status: Wrong Answer

Solution code:
N= int(input())
num=map(int, input().split())
list1=[]
result=0
y=1
for i in num:
    list1.append(i)
for x in range(0,N-1):
    while(y<N):
        sum1=list1[x]*list1[y]
        result+=sum1
        y+=1
    y-=1
print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
A = [0]*(n)
num = 1e9+7
ans = 0
for i in range(1, n):
    A[i] = A[i-1] + a[i-1]
for i in range(n-1, 0, -1):
    ans += (A[i]*a[i])%num
    ans = ans%num
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = list(map(int, input().split()))
array_sum = 0
maxN = 1000000007
for i in range(0, n, 1):
	array_sum = array_sum + arr[i] 
array_sum_square = array_sum * array_sum
individual_square_sum = 0
for i in range(0, n, 1):
	individual_square_sum += arr[i] * arr[i]
ans = (array_sum_square - individual_square_sum) / 2
print(int(ans)% maxN)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def ProductSum(A): 
    s = sum(A)
    ss = s*s
    individual_square_sum = 0
    for i in A: 
        individual_square_sum += i * i 
    return (ss - individual_square_sum) / 2
  
input()
A = list(map(int, input().split())) 
print(int(ProductSum(A)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
sumA = sum(A)
square = 0
for i in range(N):
    square += A[i] * A[i]
res = ((sumA * sumA - square)/2)%(1000000007)
print(round(res))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
N = int(input())
As = list(map(int,input().split()))
As = np.array(As)
seihokei = sum(As)**2
shoseihokei = (As**2).sum()
answer = (seihokei-shoseihokei)/2
answer = answer % (10**9+7)
print(int(answer))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
Suma = 0
for i in range(N):
    Suma += A[i]
    Suma %= 1000000007

Sum = pow(Suma, 2) % 1000000007

for i in range(N):
    Sum -= pow(A[i], 2)
    Sum %= 1000000007

print(int(Sum / 2))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
x = 0
z = 0
MOD = 10**9 + 7
for i in A:
  x = (x + i)%MOD
  z = (z + i*i)%MOD
y = x*x%MOD
w = (y-z)//2%MOD
print(w)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
A = [0]*(n)
num = 1e9+7
ans = 0
for i in range(1, n):
    A[i] = A[i-1] + a[i-1]
for i in range(n-1, 0, -1):
    ans += (A[i]*a[i])%num
    ans = ans%num
print(ans)

Submission status: Wrong Answer

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

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+=a[(i+1)*-1]
    ans+=(a[(i+2)*-1]*tmp)%(10**9+7)
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
s1=sum(l)**2
s2=0
for i in range(n):
  s2+=l[i]**2
print(int((s1-s2)/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(0, N-1):
    for j in range(i+1, N):
        if A[i]*A[j] <= 10**9 + 7:
            s+=A[i]*A[j]

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
Suma = 0
for i in range(N):
    Suma += A[i]
    Suma %= 1000000007

Sum = pow(Suma, 2) % 1000000007

for i in range(N):
    Sum -= pow(A[i], 2)
    Sum %= 1000000007

print(Sum / 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
from decimal import *
a = list(map(Decimal,input().split()))
c = Decimal(1000000007)
ans = Decimal(0)
for i in range(n-1):
    for j in range(n-i):
        if a[i] < a[i+j]:
            ans += a[i] * a[i+j]
        if ans > c:
            ans = ans % c
print(ans)

Submission status: Wrong Answer

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

n = int(input())
S = [int(a) for a in input().split()]
divisor = 10**9 + 7
tot = 0
a,b = 0,0
arr_sum = sum(S) #% divisor
arr_ssq = arr_sum*arr_sum % divisor
isq_sum = 0
for i in range(n):
  isq_sum += S[i]*S[i] #% divisor
  
#isq_sum = isq_sum % divisor
tot = (arr_ssq - isq_sum)//2 % divisor

print(tot)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

array_sum = 0
for i in range(0, n, 1): 
    array_sum = array_sum + arr[i] 
  
array_sum_square = array_sum * array_sum 
  
individual_square_sum = 0
for i in range(0, n, 1): 
    individual_square_sum += arr[i] * arr[i] 
  
b=(array_sum_square-individual_square_sum)
b=int(b)
b=b/2
b=b%1000000007
b=int(b)
print(b)

Submission status: Wrong Answer

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

data = []
by2 = []


for i in range(len(a)) :
        for j in range(len(a)) :
               data.append(a[i]*a[j] % (10**9+7))
                
for i in range(len(a)) :
       by2.append(a[i]**2 % (10**9+7))
        
ans = (sum(data)-sum(by2)) / 2

print(int(ans))

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

ans = (temp - ij)/2

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
x = 0
z = 0
MOD = 10**9 + 7
for i in A:
  x = (x + i)%MOD
  z = (z + i*i)%MOD
y = x*x%MOD
print((y-z)//2)

Submission status: Wrong Answer

Solution code:
def solve(n,A):
	mod=10**9+7
	s=0
	print(A)
	for _,x in enumerate(A):
		s+=x
	s=s**2
	squared_terms=0
	for _,x in enumerate(A):
		y=x**2
		squared_terms+=y
	ans=(s-squared_terms)//2
	return ans%mod


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

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

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) / 2
print(int(findProductSum(a,n)) % mod)

Submission status: Wrong Answer

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



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

A_sum_sq = A_sum * A_sum

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

Answer = (A_sum_sq -
          idv_sq_sum) / 2
print(Answer%(10**9 + 7))

Submission status: Wrong Answer

Solution code:
import itertools

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

mod = 10**9 + 7

ans=0
for i,j in itertools.combinations(l, 2):
  num=i*j%mod
  ans+=num
  
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = list(map(int, input().split()))
array_sum = 0
maxN = 1000000007
for i in range(0, n, 1):
	array_sum = array_sum + arr[i] 
array_sum_square = array_sum * array_sum
individual_square_sum = 0
for i in range(0, n, 1):
	individual_square_sum += arr[i] * arr[i]
print(int(((array_sum_square - individual_square_sum) / 2) % maxN))

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = [ int(x) for x in input().split() ]
j = 1
count = 0
sum = 0

for i in range(0, n - 1):
    
    while (n > j and count != n):
        mul = lst[j] * lst[i]
        sum += mul
        j += 1
        count += 1
    j = n - 1
    
print(sum)

Submission status: Wrong Answer

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


mod=1000000007
ans=0
cnt=1

for getA in A:
    for i in range(cnt,len(A)):
        ans=(ans+getA*A[i])%mod
        print(ans)
    cnt+=1


print(ans)