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())
lst=list(map(int,input().split()))
A=0
for i in range(N-1):
  for j in range(i+1,N):
    A+=lst[i]*lst[j]
    A%(10**9+7)
print(A)

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


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

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()))
ans = 0
for i in a[:n]:
    for j in a[a.index(i)+1:]:
        ans += i*j
        ans = ans%(10**9+7)
        
print(ans)

Submission status: Wrong Answer

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

def sol(lis):
    r = 0
    MAX = 10**9+7
    for i in range(len(lis)):

        for j in range(i+1,len(lis)):

            r+=((lis[i]%MAX)*(lis[j]%MAX))%MAX
    print(r)
sol(lis)

Submission status: Wrong Answer

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

if 0 in A:
    print (0)
else:
    for i in range(N):
        for j in range(i+1,N):
            if ans > (10**7):
                ans = ans % (10**7 + 7)
            ans += A[i]*A[j]

print (ans)

Submission status: Wrong Answer

Solution code:
def ProgramC():
    
    num = int(input())
    
    data = list(map(int,input().split()))

    count = 0

    for i in range(num-1):
        
        for j in range(i+1,num):
            
            count = count + data[i]*data[j]

    print(count%(pow(10,7)+7))

if __name__ == '__main__':
    ProgramC()

Submission status: Wrong Answer

Solution code:
import sys
import math
import copy
import heapq
import random
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10 ** 9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n - k])) % MOD


def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv


def renritsu(A, Y):
    # example 2x + y = 3, x + 3y = 4
    # A = [[2,1], [1,3]])
    # Y = [[3],[4]] または [3,4]
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    # [1.0, 1.0]
    return X.flatten().tolist()[0]


class TwoDimGrid:
    # 2次元座標 -> 1次元
    def __init__(self, h, w, wall="#"):
        self.h = h
        self.w = w
        self.size = (h + 2) * (w + 2)
        self.wall = wall
        self.get_grid()
        # self.init_cost()

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid

    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        # 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
        return y * (self.w + 2) + x

    def getgrid(self, x, y):
        return self.grid[y][x]

    def get(self, x, y):
        return self.cost[self.pos(x, y)]

    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return

    def show(self):
        for i in range(self.h + 2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i + 1)])

    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return

    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        # for i in range(1, self.h+1):
        #     for j in range(1, self.w+1):
        #         cx, cy = j, i
        #         for dx, dy in move_eight:
        #             nx, ny = dx + cx, dy + cy


def solve(nums=0):
    n = getN()
    nums = getList()
    sumn = sum(nums)
    ans = 0
    for num in nums:
        ans += (num * (sumn - num)) // 2
        ans %= MOD
    print(int(ans))


def solve2(nums):
    n = len(nums)
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            ans += nums[i] * nums[j]

    return (ans % MOD)
if __name__ == "__main__":
    solve()
    # for i in range(100):
    #     nums = [random.randint(0, 100) for i in range(1000)]
    #     print(nums)
    #     # main()
    #     a1 = solve(nums)
    #     a2 = solve2(nums)
    #     if a1 != a2:
    #         print(nums)
    #         print(a1)
    #         print(a2)

Submission status: Wrong Answer

Solution code:
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
 
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")
 
# ------------------- fast io --------------------
from math import gcd, ceil
 
def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi
 
 
def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans
 
def lcm(a, b): return a * b // gcd(a, b)
 
 
def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y

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

ans = 0
for i in A:
    ans += i
    ans %= MOD

sqr = ans * ans
sqr %= MOD
indsum = 0
for i in A:
    indsum += i * i
    indsum %= MOD

print((((sqr - indsum) % MOD) // 2)%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = 0

for i in range(N):
	ans = (ans +  A[i] * np.sum(A[i+1:N])) % (10**9+7)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

S = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

print(sum)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
As = np.array(list(map(int, input().split())))
m = 10**9 + 7
result = 0
a = (As.sum() ** 2)
b = (As ** 2).sum()
print(int(((a - b)/2)%m))

Submission status: Wrong Answer

Solution code:
N = int(input())

A = list(map(lambda x: int(x), input().split(' ')))

res = (sum(A)**2 - sum(list(map(lambda x: x**2, A)))) % (10**9 + 7) / 2

print(int(res))

Submission status: Wrong Answer

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

tmp = 0
tmp2 = 0

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

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

total = (tmp*tmp-tmp2)/2

print(int(total)%(1000000007))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
arr = np.array(list(map(int,input().split())))
s = np.sum(arr) ** 2 
t = np.dot(arr,arr)

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
M=0
X=(10**9)+7
Y=0
for k in range (0,N):
  M=M + A[k]
  Y=A[k]*A[k]+Y
  k=k+1
  M=M%X
newM =(M*M) %X
newY =Y%X
if newM-newY <0:
  Answer = (newM-newY+X)//2
else:
  Answer = (newM-newY)//2
print(Answer)

Submission status: Wrong Answer

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

mod = (10**9)+7
sumA = sum(A)
sumSq = sum([i*i for i in A])
print(int(((sumA*sumA-sumSq)/2))%mod)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
#n = 10**5
#a = np.array([int(10**9)]*n)
mod = 10**9+7
ans = 0
c = [0]*n
c[n-1] = a[n-1]
for i in range(n-1,1,-1) :
    c[i-1] = c[i]+a[i-1]
c.pop(0)
#print(c)
for i in range(0,n-1) :
    ans += a[i]*c[i]
    #print(a[i],c[i],ans)
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import sys
import math
import copy
import heapq
import random
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10 ** 9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n - k])) % MOD


def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv


def renritsu(A, Y):
    # example 2x + y = 3, x + 3y = 4
    # A = [[2,1], [1,3]])
    # Y = [[3],[4]] または [3,4]
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    # [1.0, 1.0]
    return X.flatten().tolist()[0]


class TwoDimGrid:
    # 2次元座標 -> 1次元
    def __init__(self, h, w, wall="#"):
        self.h = h
        self.w = w
        self.size = (h + 2) * (w + 2)
        self.wall = wall
        self.get_grid()
        # self.init_cost()

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid

    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        # 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
        return y * (self.w + 2) + x

    def getgrid(self, x, y):
        return self.grid[y][x]

    def get(self, x, y):
        return self.cost[self.pos(x, y)]

    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return

    def show(self):
        for i in range(self.h + 2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i + 1)])

    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return

    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        # for i in range(1, self.h+1):
        #     for j in range(1, self.w+1):
        #         cx, cy = j, i
        #         for dx, dy in move_eight:
        #             nx, ny = dx + cx, dy + cy


def solve(nums=0):
    n = getN()
    nums = getList()
    sumn = sum(nums)
    ans = 0
    for num in nums:
        ans += (num * (sumn - num))
        ans %= MOD
    print(int(ans // 2))


def solve2(nums):
    n = len(nums)
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            ans += nums[i] * nums[j]

    return (ans % MOD)
if __name__ == "__main__":
    solve()
    # for i in range(100):
    #     nums = [random.randint(0, 100) for i in range(1000)]
    #     print(nums)
    #     # main()
    #     a1 = solve(nums)
    #     a2 = solve2(nums)
    #     if a1 != a2:
    #         print(nums)
    #         print(a1)
    #         print(a2)

Submission status: Wrong Answer

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

print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

MOD = 10**9 + 7
# MOD = 10

sum_A = 0
for i in range(N):
    sum_A += A[i]
    sum_A %= MOD
 
ans = (sum_A * sum_A) % MOD

for i in range(N):
    ans -= (A[i] * A[i]) % MOD
    ans %= MOD

ans //= 2
ans %= MOD

print(ans)

Submission status: Wrong Answer

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
A = readInts()
a = 0
for i in range(n):
    a += A[i]
    a %= mod
a = pow(a,2,mod)
nya = 0
for i in range(n):
    nya += A[i] * A[i]
    nya %= mod
if nya > a:
    a += mod
ans = (a-nya)//2
ans %= mod
print(ans)

Submission status: Wrong Answer

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

#print(s)

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

print(int(ans))

Submission status: Wrong Answer

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

A = sum(a)
A *= A
B = 0
for ai in a:
    B += ai * ai
print(int((A - B)/ 2 % 1000000007))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  N = int(input())
  A_lst = list(map(int, input().split()))
  
  sum = 0
  for i in A_lst:
    sum += i
    sum = sum % (10**9 + 7)
  
  sum2 = 0
  for j in A_lst:
    sum2 += j * (sum-j)
    sum2 = sum2 % (10**9 + 7)

  print(sum2//2)
  
main()

Submission status: Wrong Answer

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

mod=10**9+7

sumA=sum(A)%mod

ans=0
for i in range(N):
    ans+=(A[i]*(sumA-A[i]))%mod

ans=ans//2
print(ans%mod)

Submission status: Wrong Answer

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

total = sum(a)
for i in range(N):
    ans += a[i] * (total-a[i])
ans = int(ans/2)
print(ans%(10**9 + 7))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = sorted(list(set(A)))
ans = 0
L = B.copy()
for i in range(-2,-len(B)-1,-1):
    L[i] += L[i+1]
for i in range(len(B)-1):
    ans += (B[i] * L[i+1]) % (10**9+7)
    if ans >= 10**9+7:
        ans = ans % (10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
M = 10**9 + 7
s = 0

sm = np.sum(A)

for i in range(N):
    sm -= A[i]
    s += sm * A[i]
    s = s % M

print (s)

Submission status: Wrong Answer

Solution code:
from collections import deque
import sys, copy, itertools,heapq
input = sys.stdin.readline

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

suma = sum(A)
a = (suma ** 2)

b =0
for i in range(n):
  b += A[i]*A[i]

ans = a-b
if ans < 0:
  ans += 10**9 +7

answer = ans/2
answer = answer%(10**9 +7)

print(int(answer))

Submission status: Wrong Answer

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

sum_a = 0
sum_aa = 0
for a in aaa:
  sum_a += a
  sum_aa += a ** 2
  
print(int(((sum_a ** 2 - sum_aa) / 2) % (10 ** 9 + 7)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
L = list(map(int,input().split()))
sum_L = []

for i in range(1,len(L)):
    sum_L.append(sum(L[i:]))

ans = 0

for i in range(len(L)-1):
    ans += L[i] * sum_L[i]

ans % (10**9 + 7)

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

big = pow(10,9) + 7
sums = pow(sum(a),2)
a_2 = list(map(lambda x: x ** 2, a))

print(int(((sums-sum(a_2)) / 2)%big))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
alist=list(map(int,input().split()))
MOD=10**9+7
nijo=0
for i in range(n):
    nijo+=(alist[i]**2)
gokei=sum(alist)

ans=int(((gokei**2-nijo)/2)%MOD)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())

MOD = 10 ** 9 + 7
total = 0

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

print((total % MOD) // 2)

Submission status: Wrong Answer

Solution code:
MOD = 1000000007

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

s = 0
r = 0
for a in A:
    s = (s + a)
    r = (r + a ** 2) % MOD

print(int(((s * s - r) % MOD) / 2))

Submission status: Wrong Answer

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

mod = (10**9 + 7)
ans = 0

import numpy
alistsum = numpy.cumsum(alist)

for i in range(n-1):
    ans += alist[i]*(alistsum[-1]-alistsum[i])
    ans = ans%mod

print(ans)

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 sys
def inputt():
    return sys.stdin.readline().strip()
def printt(n):
    sys.stdout.write(str(n)+'\n')
def listt():
    return [int(i) for i in inputt().split()]
n=int(inputt())
l=listt()
mu=0
c=10000000007
for a in range(n-1):
    for b in range(a+1,n):
        mu+=l[a]*l[b]
printt(mu%c)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
import numpy
ans = 0
a_r = list(reversed(a))
res = numpy.cumsum(a_r[:-1])
res_l = list(reversed(res))
for i in range(len(a)-1):
    ans += a[i]*res_l[i]
print(ans % (10**9 + 7))

Submission status: Wrong Answer

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

A = sum(a)
A *= A
B = 0
for ai in a:
    B += ai * ai
print((A - B)/ 2 % 1000000007)

Submission status: Wrong Answer

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

for ai in A:
    ans+=(ai*(s-ai)/2)
print(int(ans%(10**9+7)))

Submission status: Wrong Answer

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

MOD = 1000000007

sum_all = 0
for i in range(len(a)):
    sum_all += a[i]
sum_all %= MOD
sum = 0
for i in range(len(a)):
    sum += ((sum_all-a[i])*a[i])
    sum %= MOD

print(((sum//2) % MOD))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

print(int(ans%(1E9+7)))

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7
pres = [0]
for i in nums:
    pres.append(pres[-1] + i)
for i in range(n):
    temp = nums[i] * (pres[n] - pres[i+1])
    ans += temp
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
num_list = input().rstrip().split(' ')

sum_num = 0
for i in range(N - 1):
    for j in range(1, N):
        if i < j:
            sum_num += int(num_list[i-1]) * int(num_list[j-1])

print(sum_num)

Submission status: Wrong Answer

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

mod = 10**9 + 7
ans = 0
# for i in range(n-1):
#     for j in range(i+1,n):
#         ans += A[i]*A[j]
#         ans %= mod
sum = 0
for i in A:
    sum += i
    sum %= mod

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

print(ans)

Submission status: Wrong Answer

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

sum = 0

for i in range(n-1):
    sum_i = 0
    for j in range(n-i-1):
        sum_i += a[-(j+1)]
    print(sum_i)
    sum += (sum_i * a[i])

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

Submission status: Wrong Answer

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
A = readInts()
a = 0
for i in range(n):
    a += A[i]
    a %= mod
a = pow(a,2,mod)
nya = 0
for i in range(n):
    nya += A[i] * A[i]
    nya %= mod
ans = ((a-nya + mod)//2)%mod
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 = (s-t) % (10**9+7)
ans /= 2
print(int(ans))

Submission status: Wrong Answer

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

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

print(number)

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
A = list(map(int,input().split()))
#Aa=[]
#for i in A:
    #Aa.append(i%(10**9+7))
#print(Aa)
ans = 0

for i,j in itertools.combinations(A,2):
    #print(i,j)
    ans = ans + (i*j)%(10**9+7)
    #print(ans)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
c = sum(a)

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

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

Submission status: Wrong Answer

Solution code:
MOD = 1000000007

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

s = 0
r = 0
for a in A:
    s = (s + a)
    r = (r + a ** 2)

print(int(((s * s - r) % MOD) / 2))

Submission status: Wrong Answer

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


print(ans%mod)

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/2)%1000000007))

Submission status: Wrong Answer

Solution code:
import itertools
from numba import jit


n = int(input())
a = list(map(int, input().split()))
MOD = 10**9 + 7
ans = 0


@jit
def calc(lis):
    ans = 0
    num = len(lis)
    for i in range(num):
        for j in range(i + 1, num):
            temp = (lis[i] * lis[j]) % MOD
            ans += temp

    return ans


aa = calc(a)
print(aa)


'''
for i in itertools.combinations(a, 2):
    temp = (i[0] * i[1]) % MOD
    ans += temp

print(ans)
'''

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
M = 10**9 + 7
s = 0

for i in range(N):
    s += np.sum(A[i+1:]) * A[i]
    s = s % M

print (s)