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

sum = 0

for i in range(input_num):
    for j in range(input_num - i - 1):
        print(input_list[i], input_list[input_num -1-j])
        sum += input_list[i] * input_list[input_num -1 - j]

print(sum % 1000000007)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = 0

for i in range(input_num):
    for j in range(input_num - i - 1):
        sum += input_list[i] * input_list[input_num -1 - j]

print(sum)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())  # 個数
A = np.array([int(i) for i in input().split()], dtype=np.int64)  # 整数


sum_j = np.zeros(N-1, dtype=np.int64)
for i in range(N - 1, 0, -1):
    sum_j[i - 1] = (A[i] + (0 if i == N - 1 else sum_j[i])) % 1000000007

mod_A = np.dot(A[0:N-1], sum_j) % 1000000007

print(mod_A)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())  # 個数
A = np.array([int(i) for i in input().split()], dtype=np.int64)  # 整数


sum_j = np.zeros(N-1, dtype=np.int64)
for i in range(N - 1, 0, -1):
    sum_j[i - 1] = A[i] + (0 if i == N - 1 else sum_j[i])

mod_A = np.dot(A[0:N-1], sum_j) % 1000000007

print(mod_A)

Submission status: Wrong Answer

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

ans = total - cnt
ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[int(j)for j in input().split()]
mod=10**9+7
s=sum(l)%mod
ans=0
for i in l:
    ans=(ans+(s-i)*i)%mod
print(ans//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#-*- Coding: utf-8 -*-

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

l = 0
s = 0
for i in range(N):
    l += A[i]
    s += A[i]*A[i]
y = 0.5 * (l**2 - s)
print(int(y % (7+1e+9)))

Submission status: Wrong Answer

Solution code:
#-*- Coding: utf-8 -*-

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

N
y = 0
for i in range(N-1):
    for j in range(N):
        if i >= j:
            continue
        else:
            #print(A[i], A[j])
            x = A[i] * A[j]
            y += x
print(y)

Submission status: Wrong Answer

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

b = [0]
for i in range(1,n+1):
  b.append((a[i-1] + b[i-1]) % ((10 ** 9) + 7))
#print(b)

ans = 0
for i in range(n):
  p = b[n] - b[i+1]
  p = a[i] * p % (10**9 + 7)
  ans += p
  #print(ans,p)
print(ans)

Submission status: Wrong Answer

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

b = [0]
for i in range(1,n+1):
  b.append((a[i-1] + b[i-1]) % ((10 ** 9) + 7))
print(b)

ans = 0
for i in range(n):
  p = b[n] - b[i+1]
  p = a[i] * p % (10**9 + 7)
  ans += p
  print(ans,p)
print(ans)

Submission status: Wrong Answer

Solution code:
def solve(N, As):
    total = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            total += As[i] * As[j]
    ans = total % (9 ** 9 + 7)
    print(ans)


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split()))
    solve(N, As)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a = list(map(int,input().split()))
def p(val):
    print(val)
 
sho = 10**9 +7
a1 = sum(a)**2
b1 = list(map(lambda y:y**2,a))
b2=sum(b1)
result = ((a1-b2)/2)% sho
p(result)

Submission status: Wrong Answer

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

ans = 0
MOD = 10**9+7
total = 0

for i in range(N):
    total += A[i]
    total %= MOD

for i in range(N-1):
    tmp = A[i]
    total -= tmp
    total = total if total >= 0 else total + MOD

    ans += (tmp * total) % MOD

print(ans)

Submission status: Wrong Answer

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

sho = (10**9 +7)*2
count = 0
a1 = sum(a)**2
b1 = sum(map(lambda y:y**2,a))


result = ((a1-b1)//2)%sho

p(result)

Submission status: Wrong Answer

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

sq = 0
for i in range(len(A)):
    sq += A[i] ** 2

print(((sum(A)) ** 2 - sq) // 2)

Submission status: Wrong Answer

Solution code:
import itertools

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

ans = 0

B = list(itertools.combinations(A,2))

for i in range(len(B)):
    ans += (B[i][0] * B[i][1]) % MOD

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

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

ans = 0

B = list(itertools.combinations(A,2))

for i in range(len(B)):
    ans += B[i][0] * B[i][1] % MOD

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    sum_left = sum(a_list[1:])
    answer = 0
    for i in range(n-1):
        answer += (a_list[i] * sum_left) % (1e9 + 7)
        sum_left -= a_list[i+1]
        answer %= (1e9+7)
    print(int(answer))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    sum_left = sum(a_list[1:])
    answer = 0
    for i in range(n-1):
        answer += (a_list[i] * sum_left) % (1e9 + 7)
        sum_left -= a_list[i+1]
    print(int(answer % (1e9+7)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=input()
A=list(map(int,input().split()))
count1=0
count2=0
for a in A[0:]:
    count1=count1+a
    count2=count2+a**2

B=(count1**2-count2)/2
C=B%(10**9+7)
print(C)

Submission status: Wrong Answer

Solution code:
MOD = 1e9+7
class solution(object):
    def __init__(self, n: int, A: list)->None:
        self.n = n
        self.A = A
    
    def solve(self)->int:
        suff = [0]*self.n
        for i in reversed(range(0, len(self.A)-1)):
            suff[i]=suff[i+1]+self.A[i+1]
        ans = 0
        for i in range(0, len(self.A)):
            ans = (ans + A[i]*suff[i])%MOD 
        return int(ans)

if __name__=='__main__':
    n = int(input())
    A = [int(i) for i in input().split()]
    problem = solution(n,A)
    ans = problem.solve()
    print(ans)

Submission status: Wrong Answer

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

sq_sum_num = sum(l_num)**2
sq_list = [i**2 for i in l_num]
sq_sum_taikaku = sum(sq_list)
totals = int(((sq_sum_num - sq_sum_taikaku)/2))
total_v = totals % (10**9+7)
print(int(total_v))

Submission status: Wrong Answer

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

sq_sum_num = sum(l_num)**2
sq_list = [i**2 for i in l_num]
sq_sum_taikaku = sum(sq_list)
totals = ((sq_sum_num - sq_sum_taikaku)/2)
total_v = totals % (10**9+7)
print(int(total_v))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from numpy.core import double

N = int(input())
A = list(map(int,input().split()))
MOD = 1000000007
SUM = 0
for i in range(N-1):
    j=i+1
    for j in range(N):
        SUM += A[i] * A[j] % MOD
print(SUM)

Submission status: Wrong Answer

Solution code:
n=int(input())
hoge=list(map(int,input().split()))
ans=0
wa=hoge[0]
for i in range(1,n):
  ans+=wa*hoge[i]
  wa+=hoge[i]
print(ans)

Submission status: Wrong Answer

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

sq_sum_num = sum(l_num)**2
sq_list = [i**2 for i in l_num]
sq_sum_taikaku = sum(sq_list)
total = ((sq_sum_num - sq_sum_taikaku)/2) % (10**9 + 7)
print(int(total))

Submission status: Wrong Answer

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

sq_sum_num = sum(l_num)**2
sq_list = [i**2 for i in l_num]
sq_sum_taikaku = sum(sq_list)
total = ((sq_sum_num - sq_sum_taikaku)/2) % (10**9 + 7)
print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest

modn=1000000007

def resolve():
    n = input()
    inputs = list(map(int, input().split()))
    sum_value = sum(inputs)% modn
    ans=0
    for i in range(len(inputs)-1):
        v = inputs[i]
        sum_value = sum_value - v
        add_value = (v * sum_value) % modn
        ans+=add_value
        ans = ans%modn
    print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
1 2 3"""
        output = """11"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4
141421356 17320508 22360679 244949"""
        output = """437235829"""
        self.assertIO(input, output)


if __name__ == "__main__":
    unittest.main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,*A = map(int,open(0).read().split())

s = sum(A)
CS = [0 for i in range(N+1)]
CS[0] = s
for i in range(len(A)):
  CS[i+1] = CS[i] - A[i]
CS.pop(0)

S = 0
for i,a in enumerate(A):
  S+=CS[i]*a
  S=int(S%(1e9+7))

print(S)

Submission status: Wrong Answer

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

S = sum(A)
S2 = sum(map(lambda x:x*x,A))

print((S*S-S2)//2)

Submission status: Wrong Answer

Solution code:
def main():
    mod = 10**9+7
    #n,a = get_input()
    n = int(input())
    a = [int() for x in input().split()]
    ans = 0
    asum = sum(a) 
    for i in range(n):
        asum = asum - a[i]
        ans = ( ans + ((a[i] * asum) % mod)) % mod
    
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    mod = 1000000007
    #n,a = get_input()
    n = int(input())
    a = [int() for x in input().split()]
    ans = 0
    asum = sum(a) 
    for i in range(n):
        asum = asum - a[i]
        ans = ( ans + ((a[i] * asum) % mod)) % mod
    
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    mod = 1000000007
    #n,a = get_input()
    n = int(input())
    a = [int() for x in input().split()]
    ans = 0
    asum = sum(a)
    for i in range(n):
        asum = asum - a[i]
        ans += (a[i] * asum) % mod
    
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    mod = 1000000007
    #n,a = get_input()
    n = int(input())
    a = np.array([np.int64(x) for x in input().split()])
    ans = 0
    asum = np.sum(a)
    for i in range(n):
        asum = asum - a[i]
        ans += (a[i] * asum) % mod
    
    print(ans)
    
        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

import numpy as np


def solve(N, A):
    MOD = 10**9 + 7

    acc = np.cumsum(A)

    ans = 0
    for i in range(N - 1):
        section_sum = acc[-1] - acc[i]
        ans += A[i] * section_sum
        ans %= MOD

    return ans


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

    ans = solve(N, A)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

import numpy as np


def solve(N, A):
    MOD = 1_000_000_007

    acc = np.cumsum(A)

    ans = 0
    for i, x in enumerate(A):
        section_sum = acc[-1] - acc[i]
        ans += x * section_sum % MOD
        ans %= MOD

    return ans


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

    ans = solve(N, A)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

ans = 0
x = 0

for a in A:
    ans = (ans + a * x) % (1e9+7)
    x = (x + a) % (1e9+7)

print(ans)

Submission status: Wrong Answer

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

import numpy as np


def solve(N, A):
    acc = np.cumsum(A)

    total = 0
    for i, x in enumerate(A):
        total += x * (acc[-1] - acc[i])

    return total % (10**9 + 7)


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

    ans = solve(N, A)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

# ans = 0

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

# div, mod = divmod(ans, 1000000007)

# print(mod)

ans = 0
x = 0

for a in A:
    ans = (ans + a * x) % (1e9+7)
    x = (x + a) % (1e9+7)

print(int(ans))

Submission status: Wrong Answer

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

# ans = 0

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

# div, mod = divmod(ans, 1000000007)

# print(mod)

ans = 0
x = 0

for a in A:
    ans = (ans + a * x) % (10e9+7)
    x = (x + a) % (10e9+7)

print(int(ans))

Submission status: Wrong Answer

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

ans = 0
x = 0

for a in A:
    ans = (ans + a * x) % (1e9+7)
    x = (x + a) % (10e9+7)

print(int(ans))

Submission status: Wrong Answer

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

ans = 0
x = 0

for a in A:
    ans = (ans + a * x) % (1e9+7)
    x = (x + a) % (10e9+7)

print(ans)

Submission status: Wrong Answer

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

# ans = 0

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

# div, mod = divmod(ans, 1000000007)

# print(mod)

diag=0
for a in A:
    diag+=a**2

print(int(((sum(A)**2-diag)/2) % (1e9+7)))

Submission status: Wrong Answer

Solution code:
import itertools
N = int(input())
a = list(map(int,input().split()))
a2 = itertools.accumulate(a)
b = [0]
b += list(a2)
s = 0
for i in range(N):
    s += (a[i] * (b[-1] - b[i+1]))
print(s)

Submission status: Wrong Answer

Solution code:
import random
import numpy as np
def get_input():
    n = 200000
    a = []
    for i in range(n):
        a.append(random.randint(0,1000000000))
    aa = np.array(a,dtype='int64')
    return n,aa

def main():
    #n,a = get_input()
    n = int(input())
    a = np.array([np.int64(x) for x in input().split()])
    p = (np.sum(a) ** 2) % 1000000007
    q = np.sum(a**2) % 1000000007
    ans = p - q
    if ans < 0:
        ans += 1000000007
    if ans % 2 == 1:
        ans += 1000000007
    ans //= 2
    
    print(ans)
    
        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import random
import numpy as np
def get_input():
    n = 200000
    a = []
    for i in range(n):
        a.append(random.randint(0,1000000000))
    aa = np.array(a,dtype='int64')
    return n,aa

def main():
    #n,a = get_input()
    n = int(input())
    a = np.array([np.int64(x) for x in input().split()])
    p = (np.sum(a) ** 2) % 1000000007
    q = np.sum(a**2) % 1000000007
    if p < q:
        p += 1000000007
    ans = p - q
    if ans % 2 == 1:
        ans += 1000000007
    ans //= 2
    ans %= 1000000007
    print(ans)
    
        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import random
import numpy as np
def get_input():
    n = 200000
    a = []
    for i in range(n):
        a.append(random.randint(0,1000000000))
    aa = np.array(a,dtype='int64')
    return n,aa

def main():
    #n,a = get_input()
    n = int(input())
    a = np.array([np.int64(x) for x in input().split()])
    p = (np.sum(a) ** 2) % 1000000007
    q = np.sum(a**2) % 1000000007
    if p < q:
        p += 1000000007
    ans = p - q
    if ans % 2 == 1:
        ans += 1000000007
    ans //= 2
    print(ans)
    
        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import random
import numpy as np
def get_input():
    n = 200000
    a = []
    for i in range(n):
        a.append(random.randint(0,1000000000))
    aa = np.array(a,dtype='int64')
    return n,aa

def main():
    #n,a = get_input()
    n = int(input())
    a = np.array([np.int64(x) for x in input().split()])
    p = (np.sum(a) ** 2) % 1000000007
    q = np.sum(a**2 % 1000000007) 
    ans = (p-q)/2
    
    print(ans)
    
        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

n=int(input())  #->n=5
a=list(map(int,input().split()))  #->nl=[1,2,-,n]

temp = 0
for i in range(n-1):
    for j in range(i+1,n):
        temp = temp + a[j]
    temp = temp*a[i]
    temp = temp % (10**9+7)

print(temp)

Submission status: Wrong Answer

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

sum = 0

for i in range(N - 1):
  for j in range(i , N):
    sum += A[i] * A[j]
    
ans = sum % (1.0e+9 + 7)

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):
  for j in range(i + 1, N):
    sum += A[i] * A[j]
    
ans = sum % (1.0e+9 + 7)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans%(1e9+7))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

res = (A_sum**2 - A2)//2
ans = res%(1e9+7)
print(int(ans))

Submission status: Wrong Answer

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

# A_i^2の総和のmod(10^9+7)を計算する
tmp = sum(list(map(lambda x: (x**2)%(10**9+7), lst)))

# A_iの総和の2乗のmod(10^9+7)を計算する
tmp2 = ((sum(lst)%(10**9+7))**2)

ans = (tmp2 - tmp)%(10**9+7)//2

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
# (A合計**2)-ΣAそれぞれ**2
mod = 10**9+7
AA = sum(A)
ans = (AA%mod)**2
ans %= mod
for a in A:
    ans -= a**2
    ans %= mod
ans %= mod
print(ans//2)

Submission status: Wrong Answer

Solution code:
n=int(input())
L=[int(x) for x in input().split()]
sum=0
product=0
mod=1000000007
for i in range(n):
    sum+=L[i]%mod
for i in range(n-1):
    sum-=(L[i]%mod)
    product+=sum*(L[i]%mod)
print(product)

Submission status: Wrong Answer

Solution code:
def solve(n, a):
    t = sum(a)
    return sum((t-x)*x for x in a) // 2

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Submission status: Wrong Answer

Solution code:
n = input()
vals = list(map(int, input().split()))
s = sum(vals)
ret = 0
for i, val in enumerate(vals):
    ret += val * (s - val)

mod = 10 ** 9 + 7
print(int(ret/2) % mod)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
mod = 1e9+7
S = 0
for i in range(N):
    S += A[i]

sum = 0
for i in range(N):
    S -= A[i]
    if S<0:
        S+= mod
    sum += int(A[i]*S%(1e9+7))
    

sum = int(sum%(1e9+7))    
print(sum)

Submission status: Wrong Answer

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

S = [0]*N
S[N-1] = int(A[N-1]%(1e9+7))
for i in range(N-2,0,-1):
    S[i] = int((S[i+1] + A[i])%(1e9+7))

sum = 0    
for i in range(0,N-1):
    sum += int(A[i]*S[i+1]%(1e9+7))

sum = int(sum%(1e9+7))    
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]


s=list(np.cumsum(alst))
s.insert(0,0)

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i+1])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

s=list(np.cumsum(alst))
s.insert(0,0)
print(s)

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i+1])

print(sum%MOD)

Submission status: Wrong Answer

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

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

print(su)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]
alst=np.array(alst)



s=np.cumsum(alst)

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split()))

s=np.cumsum(alst,dtype=int)

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]

s=np.cumsum(alst,dtype=None)

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]

s=np.cumsum(alst,dtype='int64')

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]

s=np.cumsum(alst,dtype='int8')

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]

s=np.cumsum(alst,dtype='float32')

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=np.array(list(map(int,input().split()))) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]

s=alst.cumsum()

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]

s=np.cumsum(alst)

s=list(s)
sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]

s=np.cumsum(alst)

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,0+1,0+1+2,0+1+2+3,0+1+2+3+4,0+1+2+3+4+5,0+1+2+3+4+5+6]

s=[0]
for i in range(len(alst)):
  s.append(s[i]+alst[i])

print(s)
sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i+1])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np
MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,0+1,0+1+2,0+1+2+3,0+1+2+3+4,0+1+2+3+4+5,0+1+2+3+4+5+6]

s=[0]
for i in range(len(alst)):
  s.append(s[i]+alst[i])

print(s)
sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i+1])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]

s=np.cumsum(alst)
ans=[0]

for i in range(len(s)):
  ans.append(s[i])

sum=0

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

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]

s=np.cumsum(alst)
ans=[0]

for i in range(len(s)):
  ans.append(s[i])

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(ans[len(s)-1]-ans[i+1])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]

s=np.cumsum(alst)
ans=[0]

for i in range(len(s)):
  ans.append(s[i])

print(ans)
sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i+1])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

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

s=list(np.cumsum(alst))

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]

s=[0]
s=list(np.cumsum(alst))

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split()))


s=np.cumsum(alst)

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split()))


s=np.cumsum(alst)

sum=0

for i in range(len(alst)-1):
  print(i)
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

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

#全体の面積の合計
all_area = sum(a_list) * sum(a_list)

#全体から対角線の面積を引く
for i in range(n):
    all_area -= a_list[i] * a_list[i]

print((all_area/2) % ((10**9)+7))

Submission status: Wrong Answer

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

#全体の面積の合計
all_area = sum(a_list) * sum(a_list)

#全体から対角線の面積を引く
for i in range(n):
    all_area -= a_list[i] * a_list[i]

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

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=np.array(list(map(int,input().split())))


s=np.cumsum(alst)

sum=0

for i in range(len(alst)-1):
  print(i)
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=np.array(list(map(int,input().split()))) #[1,2,3]




s=np.cumsum(alst)

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)