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())
line = list(map(int, input().split()))
a = 10**9 +7
total = sum(line)%a
output = total**2 %a
for i in range(N):
    output = (output - (line[i]**2)%a)%a
print(int(output/2))

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
A=np.array(list(map(int,input().split())))
temp=sum(A)
ans=0

for i in range(N-1):
  temp-=A[i]
  ans+=A[i]*temp
  ans%=(1e+9+7)
print(int(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
s = 0
s1 = sum(l)
for x in range(n-1):
  s+=l[x]*(s1-l[x])
print(s%1000000007)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
MOD = 10**9 + 7
n=int(input())
a=list(map(int,input().split()))
sum=0
for x,y in combinations(a,2):
   sum+= x*y%MOD
print(sum)

Submission status: Wrong Answer

Solution code:
from sys import setrecursionlimit
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
from time import time
import re
setrecursionlimit(10**9)
mod=10**9+7
inf=10**18

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-08-29 21:23:19 +0900
# LastModified: 2020-08-29 21:27:55 +0900
#


import os
import sys
import numpy as np
# import pandas as pd


def main():
    n = int(input())
    a = np.array(list(map(int, input().split())))
    ans = 0
    amari = 1000000007
    for i in range(n-1):
        tmp = a[i]*np.sum(a[i+1:])%amari
        ans = (ans+tmp)%amari
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))
rev = list(reversed(a))
acc = list(accumulate(rev))
ans = 0
for i in range(n-1):
    ans += acc[i]*a[n-2-i]
print(int(ans%(1e9+7)))

Submission status: Wrong Answer

Solution code:

def findProductSum(A, n):

    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


def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    # n = len(A)
    print(int(findProductSum(A, n))%((10**9) +7))

main()

Submission status: Wrong Answer

Solution code:

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def array(size, init=0):
    return [[init for j in range(size[1])] for i in range(size[0])]


def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())


K = 10**9+7

N = II()
a = acinput()


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

# s1%=K
s2 = s1
s = (s1*s2)
T = 0
for i in range(N):
    T += a[i]*a[i]

print(int((s-T)/2 % K))

#print(s1, T)

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])*(Sum-int(A[i]))%1000000007)%1000000007

print((ans/2)%1000000007)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
total = sum(a)
for i in range(n) :
    m = a[i]
    add = 0
    add += (total-m)*m / 2
    add %= (1e9)+7
    ans += add
ans %= (1e9)+7
print(int(ans))

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
A=list(map(int, input().split()))
B=list(itertools.combinations(A, 2))
li = [B[i][0]*B[i][1] for i in range(len(B))]
print(sum(li))

Submission status: Wrong Answer

Solution code:
import itertools
z=[]
z2=[]
a=map(int, input().split())
for i in a:
    z.append(int(i))
b=list(itertools.combinations(z, 2))
for i in b:
    z2.append(i[0]*i[1])
print(sum(z2)%((10**9)+7))

Submission status: Wrong Answer

Solution code:
def main():
    N=input()
    A=list(map(float, input().split()))

    mod_value = 10**9 + 7
    sum = 0
    for i in range(len(A)-1):
        for j in range(i+1,len(A)):
           sum = sum + A[i]*A[j] % mod_value
    print(sum % mod_value)
main()

Submission status: Wrong Answer

Solution code:
import numba
from numba import njit, b1, i4, i8, f8
import numpy as np  # noqa

N = int(input())
A = np.array([int(x) for x in input().split()], dtype=np.int32)
s = 0
for i in range(N):
    s += A[i]
    s %= 10**9 + 7


def main(A, s):
    ans = 0
    for i in range(N - 1):
        s -= A[i]
        ans = (ans + A[i] * s) % (10**9 + 7)
    return ans


print(main(A, s))

Submission status: Wrong Answer

Solution code:
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)
print(int(ans/2))

Submission status: Wrong Answer

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

m=sum(i)

ans=0
for k in range(n-1):
    ans+=(i[k]*(m-i[k]))
ans=ans//2
ans=ans%(10**9+7)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

numerator= 0
tot=0

for num in aas:
  tot+=num
  numerator-= num**2

numerator+= tot**2

numerator= numerator/2

numerator= numerator%(10**9+7)
print(int(numerator))



'''
ans=0
for i in range(n-1):
  for j in range(i+1, n):
    ans+= aas[i]*aas[j]
    if ans>(10**9+7):
      ans= ans% (10**9+7)

print(ans)
'''

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
 
s, t = 0, 0
for i in range(N):
  s += A[i]
  t += A[i]**2
s = s**2

ans = int((s-t)/2)
ans %= (10**9+7)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
a = list(map(int, input().split()))
c = 0
d = 0
#print(a)
for pp in list(itertools.combinations(a,2)):
  #print(pp[0] , pp[1])
  d = int(pp[0]) * int(pp[1])
  c += d % (10**9 + 7)
print(c)

Submission status: Wrong Answer

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

out = int((sum(As)**2 - sum([a**2 for a in As]))/2)
print(out % (10**9+7))

Submission status: Wrong Answer

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

e = int(1e9 + 7)
X = sum([i for i in int_list])
square_sum = sum([i**2 for i in int_list])

#print(X, square_sum)
ans = int((X**2-square_sum)/2)
ans = int(ans%e)
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
for i in range(len(a)):
    sum += (sum_all-a[i])*a[i]

print((sum % MOD)//2)

Submission status: Wrong Answer

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

m=sum(i)

ans=0
for k in range(n-1):
    ans+=(i[k]+(m-i[k]))
ans=ans//2
ans=ans%(10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout,stderr
import time,math
from collections import defaultdict as dd
 
def pn(ob):stdout.write(str(ob))
def inp():return stdin.readline()

mod = 10**9 + 7

def main():
	n = int(inp())
	arr = list(map(int, inp().split()))

	t1 = 0
	t2 = 0

	for x in arr:
		t1 = (t1 + x) % mod
		t2 = (t2 + (x * x)% mod)% mod

	t1 = (t1 * t1) % mod
	res = (t1 - t2) 

	if(res <= 0):
		res = (res + mod) % mod

	print(res // 2)
  
if __name__ == '__main__':
	main()
	
#n,m=map(int,input().split()) 
# for i in range(n):
#     t=int(stdin.readline()) # input using fast i/p method 
#     if t%m == 0:
#         stdout.write(str(t)+'\n') #input using fast o/p method
 
# take line of integers as input
# 	arr = list(map(int, inp().split()))

Submission status: Wrong Answer

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

res = numpy.cumsum(A)

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

print(sum % 1000000007)

Submission status: Wrong Answer

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

ans = (sum**2 - sum_re)/2

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

print(int(ans))

Submission status: Wrong Answer

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

    mod = 10**9+7
    s = 0
    sq = 0
    for i in range(n):
        s += a[i]
        sq += (a[i])**2
        s %= mod
        sq %= mod

    s2 = (s**2) %mod
    ans = s2-sq
    if ans < 0:
        ans += mod
    print((ans//2)%mod)
resolve()

Submission status: Wrong Answer

Solution code:
# Efficient python 3 program to find sum 
# pair products in an array. 
mod=1000000007
# required function 
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] )%mod

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

	# 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

n=int(input())
a=input().split()
for i in range(len(a)):
    a[i]=int(a[i])
ans=findProductSum(a,n)
ans=int(ans)

ans=ans%mod
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
alist = list(map(int, input().split()))
Sum_a = 0
for i in range(N):
  Sum_j = 0
  for j in range(i+1, N):
    Sum_j += alist[j]%(1e9+7)
  Sum_a += (alist[i]%(1e9+7))*Sum_j
print(int(Sum_a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


print(findProductSum(allnum, n))

Submission status: Wrong Answer

Solution code:
import itertools
n=int(input())
a=list(map(int,input().split()))
b=0
for v in itertools.combinations(a,2):
  c=v[0]*v[1]
  if c>=10**9:
    c=c%(10**9+7)
  b+=c  
print(b)

Submission status: Wrong Answer

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

ans = 0
for a in AA:
  ans += a
ans = ans**2 % (10**9+7)
for a in AA:
  ans -= a**2  % (10**9+7)
while ans<0:
  ans += 10**9+7
print(int(ans/2))

Submission status: Wrong Answer

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

for i in range(0, n, 1): 
    arr_sum = arr_sum + arr[i] 

temp = arr_sum * arr_sum  
temp1 = 0

for i in range(0, n, 1): 
    temp1 += arr[i] * arr[i] 
print((temp - temp1)//2)

Submission status: Wrong Answer

Solution code:
# AtCoder Beginner Contest 177
# C - Sum of product of pairs

from itertools import combinations

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

mod=10**9+7

ans=0

for v in combinations(ls,2):
    print(v[0],v[1],v[0]*v[1],(v[0]*v[1]%mod))
    ans+= (v[0]*v[1])%mod
    ans%=mod

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

e = int(1e9 + 7)
X = sum([i for i in int_list])
square_sum = sum([i**2 for i in int_list])

#print(X, square_sum)
ans = int(((X**2-square_sum)%e)/2)

print(ans)

Submission status: Wrong Answer

Solution code:
MOD = 10**9+7
n = input()
a = list(map(int, input().split()))
ans = 0
for i, ai in enumerate(a):
  if i == len(a)-1:
    continue
  for aj in a[i+1:]:
    ans += (ai*aj)%MOD

print(ans)

Submission status: Wrong Answer

Solution code:
N = 3
alist = [1, 2, 3]
Sum_a = 0
for i in range(N):
  Sum_j = 0
  for j in range(i+1, N):
    Sum_j += alist[j]%(1e9+7)
  Sum_a += (alist[i]%(1e9+7))*Sum_j
print(int(Sum_a))

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int, input().split()))
import itertools
sum = 0
for p in list(itertools.combinations(l, 2)):    
    if p[1] != p[0]:
        sum+= (p[0] * p[1])

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

Submission status: Wrong Answer

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

sum_arr = sum(arr) % mod
sum_pow = 0

for a in arr:
  sum_pow = (sum_pow + a*a) % mod

result = ((sum_arr*sum_arr % mod) - sum_pow ) % mod //2

print(result)

Submission status: Wrong Answer

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

    mod = 10**9+7
    s = 0
    sq = 0
    for i in range(n):
        s += a[i]
        sq += (a[i])**2
        s %= mod
        sq %= mod

    s2 = (s**2) %mod
    ans = s2-sq
    if ans < 0:
        ans += mod
    print((ans%mod)//2)
resolve()

Submission status: Wrong Answer

Solution code:
modulo=10**9+7
N=int(input())
array=[int(x) for x in input().split()]
total=((sum(array))**2)%modulo
for i in array:
	total=(total-((i%modulo)**2))%modulo
print(((total//2))%modulo)

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
A = inpl()

ss = sum(A)
s = 0
for i in range(len(A)):
    s = (s + (ss-A[i]) * A[i]) % mod

print(s//2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
N = int(readline())
A = list(map(int,readline().split()))
total = sum(A)
B = [0] * N
for i in range(N):
    B[i] = total-A[i]
ans = 0 
for i in range(N):
    ans += A[i]*B[i]
    if ans >= 2*MOD:
        ans %= MOD
print(ans//2)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = input()
A = list(map(int,input().split()))
s = 0
for i in range(len(A)):
  for j in range(i+1,len(A)):
    s = s + A[i]*A[j]
    
print(s)

Submission status: Wrong Answer

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

import sys

DEBUG = False


def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep=" "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


MOD = 1e9 + 7


def solve(as_):
    all_sum = 0
    for a in as_:
        all_sum = (all_sum + a) % MOD
    ans_x2 = 0
    for i in range(0, len(as_)):
        ans_x2 = (
            ans_x2 + ((MOD + (all_sum - as_[i]) % MOD) % MOD) * as_[i]) % MOD

    return int(ans_x2 // 2)


def main():
    _n = read(int)
    as_ = read_list(int)
    print(solve(as_))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(str(s))

Submission status: Wrong Answer

Solution code:
n= int(input())
lst = [int(i) for i in input().split()]
count = 0
d_lst = []
for i in range(len(lst)):
  for j in range(i+1,len(lst)):
    # print(i,j)
    a = lst[i] * lst[j]
    if a not in d_lst:
      if lst.count(lst[i]) == 1:
        count += a
      else:
        lst.append(a)
if count > ( 10**9 + 7 ):
  print(count % (10**9 + 7))
else:
  print(count)

Submission status: Wrong Answer

Solution code:

def findProductSum(A, n):

    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

# Driver code
if __name__ == '__main__':
    n = int(input())
    A = [int(x) for x in input().split()]
    # n = len(A)
    print((findProductSum(A, n)%(10**9 +7)))

Submission status: Wrong Answer

Solution code:
MOD=10**9+7
N=int(input())
A=list(map(int,input().split()))
a_sum=sum(A)%MOD
ans=(a_sum**2)%MOD
ans-=sum(map(lambda x: x*x%MOD, A))%MOD
print(ans%MOD//2)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())

A_list = [int(_) for _ in input().split()]
sum_of_A_sq = sum(A_list)**2
sum_of_sq_A = sum([_**2 for _ in A_list])

ans = (sum_of_A_sq-sum_of_sq_A)/2.0
ans = ans%(10**9+7)

print(int(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = list(map(int, input().split()))
s = 0
for ind, i in enumerate(lis):
   for j in lis[ind+1:]:
        print(i, j)
print(s % 1000000009)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N= int(input())
A= list(map(int,input().split(' ')))

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

print(ans)

Submission status: Wrong Answer

Solution code:
def findProductSum(A, n): 
    array_sum = sum(A)
    array_sum_square = array_sum ** 2
    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

n = input()
arr = list(map(int, input().split()))
res = findProductSum(arr, len(arr)) % (10**9 + 7)
print(int(res))

Submission status: Wrong Answer

Solution code:
# Date [ 2020-08-29 21:10:46 ]
# Problem [ c.py ]
# Author Koki_tkg

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    n = read_int()
    a = read_int_list()
    
    ans = 0

    total = sum(a)
    for i in range(n):
        ans += (a[i] * (total - a[i])) / 2
        ans %= MOD

    print(int(ans % MOD))

if __name__ == '__main__':
    Main()

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 
    return (array_sum_square - 
            individual_square_sum) / 2
  
# Driver code 
if __name__ == '__main__': 
    n = int(input())
    lol=[int(n) for n in input().split()]
     
    print(int(findProductSum(lol, n))%1000000007)

Submission status: Wrong Answer

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

print(sum)

Submission status: Wrong Answer

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

o = 0

for i in range(0, n-1):
    num1 = a[i]
    for j in range(i+1, n):
        num2 = a[j]
        product = num1 * num2
        print(product, i, j)

        o += product
print(o % ((10**9)+7))

Submission status: Wrong Answer

Solution code:
# Efficient python 3 program to find sum 
# pair products in an array. 

# required function 

big = pow(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) / 2
    # Driver code 
if __name__ == '__main__': 
  n = int(input())
  A = list(map(int, input().split()))
  print(int(findProductSum(A, n) % big))

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

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 
    return (array_sum_square - 
            individual_square_sum) / 2
  
# Driver code 
if __name__ == '__main__': 
    n = int(input())
    lol=[int(n) for n in input().split()]
     
    print(int(findProductSum(lol, n)))

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 -ans2)//2)

Submission status: Wrong Answer

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

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])*(Sum-int(A[i]))%1000000007)%1000000007

print(int(ans%1000000007/2))

Submission status: Wrong Answer

Solution code:
N = int(input())
A_list = [int(_) for _ in input().split()]
sum_of_A_sq = sum(A_list)
sum_of_sq_A = sum([_**2 for _ in A_list])

ans = (sum_of_A_sq**2-sum_of_sq_A)/2
ans = ans%(10**9+7)

print(int(ans))

Submission status: Wrong Answer

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

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

mod = 10**9 + 7

a_sum = sum(a_list)

ans = 0
for i in range(0, n):
    ans += (a_list[i] * (a_sum - a_list[i]))
# print(int((ans%mod)/2))
print(int((ans/2%mod)))

Submission status: Wrong Answer

Solution code:

def findProductSum(A, n):

    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

# Driver code
if __name__ == '__main__':
    n = int(input())
    A = [int(x) for x in input().split()]
    # n = len(A)
    print(int(findProductSum(A, n)%(10**9 +7)))

Submission status: Wrong Answer

Solution code:
# Date [ 2020-08-29 21:10:46 ]
# Problem [ c.py ]
# Author Koki_tkg

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    n = read_int()
    a = read_int_list()
    
    ans = 0

    total = sum(a)
    for i in range(n):
        ans += (a[i] * (total - a[i])) / 2
        ans %= MOD

    print(ans % MOD)

if __name__ == '__main__':
    Main()

Submission status: Wrong Answer

Solution code:
m=1e9+7

def findProductSum(A, n): 
	
	array_sum = 0
	for i in range(0, n, 1): 
		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 = (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(int(int(findProductSum(A, n))%m))

Submission status: Wrong Answer

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