Problem:


Score : 300 points

Problem Statement

Given are N integers A_1,\ldots,A_N.

Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Constraints

2 \leq N \leq 2\times 10^5

0 \leq A_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 \ldots A_N

Output

Print \sum_{i=1}^{N-1}\sum_{j=i+1}^{N} A_i A_j, modulo (10^9+7).

Sample Input 1

3
1 2 3

Sample Output 1

11

We have 1 \times 2 + 1 \times 3 + 2 \times 3 = 11.

Sample Input 2

4
141421356 17320508 22360679 244949

Sample Output 2

437235829



Sample input:
3
1 2 3


Sample output:
11

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np
n = int(input())
l = list(map(int,input().split()))
nums = []
for v in itertools.combinations(l, 2):
    nums.append(v[0]*v[1])
S = np.sum(nums)
print(S%10**9+7)

Submission status: Wrong Answer

Solution code:
n=int(input())
b=input().split()
i=0
j=1
s=0
while i<(n-1):
    if j==n:
        i+=1
        j=i+1
    else:
        s=(s+(int(b[i])*int(b[j])))
        j+=1
print(s)

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 i < j:
            S += A[i] * A[j]
print(S)

Submission status: Wrong Answer

Solution code:
import sys
import array
import numpy as np

N = int(input())
A = list(map(int, input().split()))
def SumProduct(xList):
    xSum = 0
    for xnr, x in enumerate(xList):
     #print xnr, x
       xList_1 = np.array(xList[xnr+1:])
            #print x * xList_1
       xSum = xSum + sum(x * xList_1)
    return xSum

print(SumProduct(A))

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]**2
    E += A[i]

ans =int(((E**2 - P)/2)%(10**9+7))
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):
    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()))
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%mod)**2)%mod-sum2%mod)%mod)/2
print(int(ans%mod))

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce

n = int(input())
a = list(map(int, input().split()))
flag =1
if reduce(math.gcd, a) != 1:
        print("not coprime")
        flag = 0
if flag == 1:
        for i  in range(n):
                for j in range(n):
                        if a[i] != a[j]:
                                if math.gcd(a[i], a[j]) != 1:
                                        print("setwise coprime")
                                        flag = 0
                                        break
                        else:
                                continue
                break
if flag == 1:
        print("pairwise coprime")

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] * l[j] % MOD
#        print(str(l[i]) + " * " + str(l[j]))
print(x)

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
  ans = ans % (10**9+7)
  for a in AA:
    ans -= a**2
    ans = ans % (10**9+7)
  ans = ans % (10**9+7)
  if ans<0:
    ans += 10**9+7
  print(int(ans/2))
solve()

Submission status: Wrong Answer

Solution code:
import decimal


def resolve():
    n = int(input())
    A = list(map(decimal.Decimal, 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:
# 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 % 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 += ((A[i] % 1000000007) * (A[i] % 1000000007)) % 1000000007
  
    # required sum is (array_sum_square - 
    # individual_square_sum) / 2 
    return (((array_sum_square % 1000000007) - 
            (individual_square_sum % 1000000007)) / 2) % 1000000007
 
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
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 = s - h[i]
    ans = ans + h[i] * s
ans = ans % (10 ** 9 + 7)
print(int(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
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 = 10 ** 9 + 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 = sum(A) % mod
    q = sum([a ** 2 % mod for a in A]) % mod
    ans = (((s * s) % mod - q) % mod) / 2
    print(int(ans % mod))


if __name__ == '__main__':
    main()

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+=((sum(A)-A[i])%MOD)*A[i]/2
  c%=MOD
print(int(c))

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))

a = np.array(a, dtype=np.uint64)
s = ((
    (np.sum(a)**2).astype(np.uint64) - np.sum(a**2)
) // 2).astype(np.uint64)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A_list = list(map(int,input().split()))
sum1 = 0

for i in range(N):
        for j in range(i+1,N):
            B = A_list[i]%1000000007
            C = A_list[j]%1000000007
            sum1 += B*C

print(sum1)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np
input = stdin.readline
n = input().rstrip()
n = int(n)
a = list(map(int, input().split()))
a = np.array(a)
suma = np.cumsum(np.array(a))

ans = 0
for i in range(n-1):
    x = suma[n-1] - suma[i]
    ans += a[i] * x

ans %= 1000000007

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
s = 0
t = 0
b = 0
m = 10 ** 9 + 7
for i in range(n):
    t += a[i]
    t = t % m
    b += a[i] ** 2
    b = b % m
s += int((((t ** 2) % m + m - b) % m) / 2)
print(s)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(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:
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 = sum(A)
    q = sum([a ** 2 % mod for a in A]) % mod
    ans = (((s * s) % mod - q) % mod) / 2
    print(int(ans % mod))


if __name__ == '__main__':
    main()

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
print(int(Sum/2)+1)

Submission status: Wrong Answer

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

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] 

  




    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

  

if __name__ == '__main__':  
  
    n=int(input())
    A = list(map(int,input().split()))

    

    print(int(findProductSum(A, n)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

sums = sums*sums;
suma = 0
for i in range(n):
    suma += a[i]*a[i]

ans = (sums - suma) / 2
ans %= 1000000007

if (ans < 0):
    ans += 1000000007
    ans /= 2
    
print(int(ans))

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(map(int, input().split()))
c = 1
d= 0
e = b[0]*b[-1]

for i in range(0, a-1):
    c =b[i]*b[i+1]
    d = d + c
B= d +e
print(B%1000000007)

Submission status: Wrong Answer

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

s = sum(a)
aa = sum(list(map(lambda x: x**2, a)))

total = int((s**2 - aa) / 2) % (10**9 + 7)
print(total)

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
  ans = ans % (10**9+7)
  for a in AA:
    aa = (a**2) % (10**9+7)
    ans -= aa
    while ans<0:
      ans += 10**9+7
  ans = ans % (10**9+7)
  print(int(ans/2))
solve()

Submission status: Wrong Answer

Solution code:
# 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]) % 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 += (A[i] * A[i]) % 1000000007
  
    # required sum is (array_sum_square - 
    # individual_square_sum) / 2 
    return ((array_sum_square % 1000000007) - 
            (individual_square_sum % 1000000007)) / 2
 
N = int(input())
A = list(map(int, input().split()))
 
print(int(findProductSum(A, N) % 1000000007))

Submission status: Wrong Answer

Solution code:
from numba import jit
import numpy as np

@jit
def main():
    N = int(input())
    A = np.array(list(map(int, input().split())), dtype=np.int64)
    mod = 10**9 + 7

    answer = 0
    for i in range(N):
        answer = answer % mod +  A[i] % mod * (A[i+1:]).sum() % mod

    print(answer)

main()

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 % ((10 * 9) + 7))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int, input().split()))
s1 = sum(a)
a2 = np.array(a,dtype=int)
a3 = a2**2
s2 = sum(a3)
print(((int(s1**2)-int(s2))//2)%(int(10**9)+int(7)))

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)
ans=ans/2
print(int(ans%1000000007))

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

MOD = 1000000007
n = int(input())
ai = list(map(int,input().split()))
ans = 0

for v in itertools.permutations(ai, 2):
    print(v)
    ans += np.prod(v)
    
print(ans % MOD)

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
print(Sum/2)

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 1 <= i < j <= N:
            S += A[i] * A[j]
print(S)

Submission status: Wrong Answer

Solution code:
n = 2 # nは入力回数
num_list = []
for i in range(n):
    num_list.append(list(map(int,input().split())))
print(num_list)

N = num_list[0]
A = num_list[1]


Sum = 0
mod_n = 10.0E8 +7

for i in range(N[0]-1):
    for j in range(i+1,N[0]):
        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()))
result = 0 
import numpy as np
num = np.array(a)
for i, a in enumerate(num):
    sum = np.sum(a*num[(i+1):])
    result += sum
if result >= (10**9 + 7):
    print(result % (10 ** 9 +7))
else:
    print(result)

Submission status: Wrong Answer

Solution code:
from scipy.special import comb

n=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(0,n-1):
    s=0
    for j in range(i+1,n):
        s+=A[j]
    s%=10**9+7
    ans+=(A[i]*s)%(10**9+7)
    
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 = sum(A)
    q = sum([a ** 2 for a in A]) % mod
    ans = (((s * s) % mod - q) % mod) / 2
    print(int(ans % mod))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(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]
            ans+=temp
        ans%=MOD

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A_list = list(map(int,input().split()))
sum1 = 0

for i in range(N):
        for j in range(i+1,N):
            sum1 += (A_list[i]*A_list[j])%1000000007

print(sum1)

Submission status: Wrong Answer

Solution code:
import itertools
def NextInts(): return map(int,input().split())

saisyo = input()
X = NextInts()
ANSWER = 0
MOD = 10**9+7
for i in itertools.combinations(X, 2):
	answer = (int(i[0])*int(i[1]))
	ANSWER+=answer%MOD
print(ANSWER)

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
len_s=len(s)
len_t=len(t)
len_n=len_s-len_t
ans=100000
for i in range(0,len_n+1):
    cnt=0
    for j in range(len_t):
        if s[i+j]!=t[j]:
            cnt+=1

    ans=min(ans,cnt)
print(ans)

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])%mod)

ans=0
for i in range(n-1,0,-1):
    ans = (ans + a[i]*pref[i-1])%mod


print(int(ans))

Submission status: Wrong Answer

Solution code:
# 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])
  
    # 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 += (A[i] * A[i]) % 1000000007
  
    # required sum is (array_sum_square - 
    # individual_square_sum) / 2 
    return (array_sum_square - 
            individual_square_sum) / 2
 
N = int(input())
A = list(map(int, input().split()))
 
print(int(findProductSum(A, N) % 1000000007))

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int, input().split()))
S = 0
T = 0
for i in range(N):
  S += As[i]
  T += As[i] * As[i]
# print(S)
# print(T)
A = S*S % 1000000007
B = T % 1000000007
print(int((A - B)/2) % 1000000007)

Submission status: Wrong Answer

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

s = sum(lis) ** 2
ss = sum([i ** 2 for i in lis])

print(((s - ss)//2)%1000000009)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = np.array([int(i) for i in input().split()])
B = np.cumsum(A[::-1])[::-1]
res = 0
for i in range(N-1):
    res = (res + A[i] * B[i+1]) % (10**9+7)
print(res)

Submission status: Wrong Answer

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

@njit
def solve(n, a):
    ans = 0
    for i in range(n-1):
        for j in range(i+1, n):
            ans += a[i]*a[j]
    return ans%((10**9)+7)
    
print(solve(N, A))

Submission status: Wrong Answer

Solution code:
# 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]) % 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 += (A[i] * A[i]) % 1000000007
  
    # required sum is (array_sum_square - 
    # individual_square_sum) / 2 
    return (array_sum_square - 
            individual_square_sum) / 2
 
N = int(input())
A = list(map(int, input().split()))
 
print(int(findProductSum(A, N) % 1000000007))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def calu(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 += a[i] * a[i]

    return int((array_sum_square - individual_square_sum) / 2)


ans = calu(a, n) % mod
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s = sum(a)
aa = sum(list(map(lambda x: x**2, a)))

total = int(((s**2 - aa) / 2) % (10**9 + 7))
 
  
print(total)

Submission status: Wrong Answer

Solution code:
import itertools
def NextInts(): return map(int,input().split())

saisyo = input()
X = NextInts()
ANSWER = 0
MOD = 10**9+7
for i in itertools.combinations(X, 2):
	answer = (int(i[0])*int(i[1]))
	ANSWER+=answer
print(ANSWER)

Submission status: Wrong Answer

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

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)
    ans %= 1000000007

print(int(ans/2))

Submission status: Wrong Answer

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

ans %= mod
print(int(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 = (k / 2) % ((10 ** 9) + 7)
print(math.floor(x))

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=(tmp+a[(i+1)*-1])%(10**9+7)
    s[(i+1)*-1]=tmp
    
print((s*(a[:-1]%(10**9+7))).sum()%(10**9+7))

Submission status: Wrong Answer

Solution code:
import itertools

N = 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)

Submission status: Wrong Answer

Solution code:
# 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] 
  
    # 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 += (A[i] * A[i]) % 1000000007
  
    # required sum is (array_sum_square - 
    # individual_square_sum) / 2 
    return (array_sum_square - 
            individual_square_sum) / 2
 
N = int(input())
A = list(map(int, input().split()))
 
print(int(findProductSum(A, N) % 1000000007))

Submission status: Wrong Answer

Solution code:
N = int(input())
input1 = input()
input1 = input1.split()
A = []
for i in input1:
    A.append(int(i))
sum = 0
for i in range(N):    
    sum = sum + A[i]
sum_square = sum*sum
individual_square_sum = 0
for i in range(N):
    individual_square_sum = individual_square_sum + A[i]*A[i]
result = int((sum_square - individual_square_sum) / 2)
print(result)

Submission status: Wrong Answer

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

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

sums *= sums;
ans = sums;

for i in range(n):
    ans -= a[i]*a[i]
ans /= 2
ans %= 1000000007
print(int(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(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]
            ans+=temp

print(ans%MOD)

Submission status: Wrong Answer

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

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])))
    ans %= 1000000007

print(int(ans/2))

Submission status: Wrong Answer

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

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

mod_num = 1e9 + 7

tmp_sum = 0
mod_lst = []
for i in range(N-1):
    for j in range(i+1, N):
        tmp_sum+=(A[i]*A[j])%mod_num
        print(i,j)
        if tmp_sum>mod_num:
            tmp = tmp_sum%mod_num
            mod_lst.append(tmp)
            tmp_sum = 0

if len(mod_lst)!=0:
    tmp_sum = 0
    flag = True
    while flag:
        print(flag)
        print(mod_lst)
        tmp_mod_lst = []
        for m in mod_lst:
            tmp_sum+=m
            if tmp_sum>mod_num:
                tmp = tmp_sum%mod_num
                tmp_mod_lst.append(tmp)
                tmp_sum = 0
        if len(tmp_mod_lst) == 0:
            print(tmp_sum)
            flag=False
        if len(tmp_mod_lst) == 1:
            print(int(tmp_mod_lst[0]))
            flag = False
        else:
            mod_lst = tmp_mod_lst
else:
    print(int(tmp_sum))

Submission status: Wrong Answer

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

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

sums *= sums;
ans = sums;

for i in range(n):
    ans -= a[i]*a[i]
ans /= 2

ans %= 1000000007
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
numbers = list(map(int, input().split()))
numbers = [i % 1000000007 for i in numbers]

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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



count = 0

b_list = a_list



for i in range(n-1):

    for k in range(len(b_list[i+1:])):
        count += a_list[i] * b_list[i+1:][k]

print(count)