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: Runtime Error

Solution code:
import resource;
import random
# 再帰回数上弦を100000回に設定
sys.setrecursionlimit(100000)
# スタックサイズを無制限に設定
resource.setrlimit(resource.RLIMIT_STACK, (-1, -1))

n = int(input(''))
adl = input('')

a = list(map(int,adl.split(' ')))

number = 0

mod = 7+1000000000

amari = 0

for i in range(n):
    aa = 0
    for e in range(n-i-1):
        j = i+e+1
        if i != j:
            aa = aa + a[j]
    number = number + (a[i] * aa)
amari = number % mod
print(amari)

Submission status: Runtime Error

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

partial_sum = copy.deepcopy(A)
sum_now = A[N-1]
for j in range(N-2,-1,-1):
    sum_now = int((sum_now+A[j])%mod)
    partial_sum[j] = sum_now
res = 0
for i in range(N-1):
    res = (res + (A[i]*partial_sum[i+1])%mod) %mod
print(int(res))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
tmp = list(map(int, input().split()))
A = [a % M for a in tmp]
M = 1000000007
ans = 0
for i in range(1,n):
    ans += (A[i-1] * ((sum(A[i::])%M)))%M
print(ans%M)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <numeric>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007

int main()
{
    int n;cin >> n;
    vector<ll> a(n);
    vector<ll> b(n-1);
    rep(i,n) {
        cin >> a[i];
    }

    ll ans = 0;
    ll sum = 0;
    ll sums = 0;
    for (int i = 1; i < n; i++)
    {
        sum += a[i];  
    }


    int i = 1;
    for(int j = 0; j < n - 1; j++) {
        b[j] = sum;
        sum -= a[i++];
    }

    for(int i = 0; i < n - 1; i++) {
        ans += b[i]*a[i];
        ans %= mod;
    }



    cout << ans << endl;

}

Submission status: Runtime Error

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

mod=10**9+7
import numpy as np
total = sum(a)
cum=[]

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

print(ans%mod)

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split()
print(a)
import numpy as np
arr = np.zeros((n,n))
for i in range(n):
    arr[i,:] = [float(s) for s in a]
arr = np.triu(arr,k=-1)
print(int(np.sum(arr)))

Submission status: Runtime Error

Solution code:
hu

Submission status: Runtime Error

Solution code:
from C import ans


n = int(input())
n_list = [int(i) for i in input().split()]

s = sum(a**2 for a in n_list)
ans = sum(n_list) ** 2 - s

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

Submission status: Runtime Error

Solution code:
def solve():
  N = int(input())
  AA = list(map(int,input().split()))
 
  ans = 0
  for a in AA:
    ans += a
  ans = ans**2
  for a in AA:
    ans -= a**2
  ans = ans//2
  print(ans%(10**9+7)
solve()

Submission status: Runtime Error

Solution code:
import numpy as np
A = np.asarray(input().split()).astype(np.int)
 
ans = 0
mod = 10**9 + 7
for i in range(N):
    pA = (A[i] % mod) * (A[i+1:].sum() % mod)
    ans += pA
 
print(int(ans % mod))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A = np.asarray(input().split()).astype(np.int)
 
ans = 0
mod = 10**9 + 7
for i in range(N):
    pA = (A[i] % mod) * (A[i+1:].sum() % mod)
    ans += pA
 
print(int(ans % mod))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
 
import sys
import math
import numpy as np
import copy

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

#行列生成
aa = []
ab = []

a1 = np.array(a)
a2 = np.tril(np.tile(a1, (len(a), 1)).T)
#print(a2)
#np.fill_diagonal(a2, 0)
a3 = a1.T

#print(a1 * a2)
sum_n = np.sum(a2 * a3)
print(sum_n % (1000000000 + 7))
#print(sum_n, a2)

#print((a2 * a3), np.square(a1))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split(" ")))
s = 0
for i in range(0,N):
  s += a[i]

s = s*s

for i in range(0,N):
  s -= a[i]*a[i]

while s >= 2*(10**9 +7):
  s = int(s % (10**9 +7))
s = s/2
 
print(int(ss))

Submission status: Runtime Error

Solution code:
n = int(input())

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

sigma = 0
after = sum(a[0:])
for i in range(len(a)-1):
  start = a[i]
  after = after - [i]
  if after >= (10**9 + 7):
    after = after % (10**9+7)
  sigma = sigma + start * after
  if sigma >= (10**9 + 7):
    sigma = sigma % (10**9+7)

print(sigma)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
 
import sys
import math
import numpy as np
import copy

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

#行列生成
aa = []
ab = []

a1 = np.array(a)
a2 = np.tile(a1, (len(a), 1)).T
#print(a2)
np.fill_diagonal(a2, 0)
a3 = a1.T

#print(a1 * a2)
sum_n = np.sum(a2 * a3) // 2
print(sum_n % (1000000000 + 7))
#print(sum_n, a2)

#print((a2 * a3), np.square(a1))

Submission status: Runtime Error

Solution code:
n = int(input())
A = [int(x)%(1e9+7) for x in input().split()]

# calculating array sum (a1 + a2 ... + an) 
array_sum = 0
for i in range(0, n, 1): 
    array_sum = (array_sum + A[i])%(1e9+7)

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

# 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])%(1e9+7)
    individual_square_sum = individual_square_sum%(1e9+7)

# required sum is (array_sum_square - individual_square_sum) / 2 
print (array_sum_square - individual_square_sum) / 2

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 29 22:19:15 2020

@author: naoki
"""

N = int(input())

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

count1 = 0
count2 = 0
count = 10**9 +7
for i in A:
    count1+=i
	count1=count1%count
for j in A:
    count2 = j*(count1-j)%count + count2
    count1 = count1 -j 
    
print(count2%count)

Submission status: Runtime Error

Solution code:
n = int(input())
m = 1e9 + 7
a = []
s = 0
r = 0
for _ in range(n):
    x = int(input())
    a.append(x)
    s += x
    r += x * x
s *= s
ans = (s - r) / 2
ans %= m
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

def main():
    n = int(input())
    A_ = [int(x) for x in input().split()]
    A = [a for a in A_ if a != 0]
    N = len(A)

    # mod = 10**9+7
    mod = 200003
    PR = 2
    order = [1]
    x = PR
    while x != 1:
        order.append(x)
        x *= PR
        x %= mod

    order_l = len(order)
    where = np.zeros(mod, int)
    for i in range(order_l):
        where[order[i]] = i
    prevCnt = np.zeros(mod, int)
    resCnt = np.zeros(mod, int)
    for n in range(N):
        if A[n] != 0:
            prevCnt[where[A[n]]] += 1
            resCnt[(A[n] * A[n]) % mod ] -= 1
    N_=1
    while N_ < 2*len(prevCnt): N_ *= 2
    nf = np.zeros(N_,int)
    nf[:len(prevCnt)]=prevCnt
    nf=np.fft.rfft(nf)
    fftRes = np.rint( np.fft.irfft(nf*nf))
    for r in range(len(fftRes)):
        if fftRes[r] != 0:
            resCnt[order[r % order_l]] += fftRes[r]
    ans = 0
    for p in range(mod):
        if resCnt[p] != 0:
            ans += (resCnt[p] // 2) * p
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
#define MOD (ll) (1e9+7)
int main()
{
     ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> sum(N);
    for(size_t i=0;i<N; i++)
    {
        cin >> A[i];
    }
    for(ll i=N-2;i>=0;i--)
    {
        sum[i] = (sum[i+1] + A[i+1]) % MOD;
    }

    ll total = 0;
    for(size_t i=0;i<N-1; i++)
    {
        total+= (A[i] * sum[i]) %MOD;
        total %= MOD;
    }
    cout<<total<<"\n";
}

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int,input().split()))
t = [];s = 0
for i in range(N):
    for j in range(N):
        if i != j:
            if a[i]*a[j]<10**9+7:
                t.append(a[i]*a[j])
            else:
                t.append(a[i]%7*a%[j]%7)
for i in t:
    s += i
s = s//2
print(s%10**9+7)

Submission status: Runtime Error

Solution code:
S = input()
T = input()
print(S)
print(T)
num = []
for i in range(len(T)):
    _T = T[i:]
    for j in range(len(T)-i):
        _T_ = _T if j == 0 else _T[:-j]
        base = S[i:-j] if j != 0 else S[i:]
        if _T_ in base:
            num.append(len(T)-len(_T_))
print(num)
print(min(num))

Submission status: Runtime Error

Solution code:
#import numpy as np
N = int(input())
#A = np.array(list(map(int,input().split(" ")))) % MOD
A = list(map(int,input().split(" ")))
MOD = 10**9 + 7
ans = 0
#print(A)
table = np.outer(A,A) % MOD
#print(table)
#print(A)
for i in range(0,len(A)):
    raw = 0
    for j in range(i+1,len(A)):
        raw += A[j]
        raw = raw % MOD
    ans += A[i] * raw
    ans = ans % MOD
#    raw = 0
#    for j in range(i+1,len(A)):
#        raw = (raw + A[j]) % MOD
#        raw = raw % MOD
#    else:
#        raw = raw % MOD
#    ans = (ans + A[i] * raw) % MOD
#    print(ans)
#        print(np.sum(table[i][j]) % MOD)
#        ans = (ans + np.sum(table[i][j])) % MOD
#        print(ans)
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
numbers = np.array(list(map(int, input().split())))
ii, jj = np.meshgrid(range(N), range(N))
xx, yy = np.meshgrid(numbers, numbers)
times = xx * yy
times_sum = np.where(ii < jj, times, 0).sum()
print(int(times_sum) % int(1e+9 + 7))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

sum_ += sum(a * (tmp - a) for a in A)

print(sum_)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
numbers = np.array(list(map(int, input().split())))
ii, jj = np.meshgrid(range(N), range(N))
xx, yy = np.meshgrid(numbers, numbers)
times = xx * yy
times_sum = np.where(ii < jj, times, 0).sum()
print(int(times_sum % int(1e+9 + 7)))

Submission status: Runtime Error

Solution code:
from sys import stdin

n = stdin.readline().rstrip().split()[0]
A = [int(x) for x in stdin.readline().rstrip().split()]

s = str(int((sum(A)**2 - sum([a**2 for a in A])) / 2))

if(int(s) < (10**9 + 7)):
    print(int(s))

x = int(s[-9:]) - 7 * int(s[:-9])
if(x < 0):
    print(x % (10**9 + 7))
else:
    print(x)

Submission status: Runtime Error

Solution code:
#
# 177C
#
import itertools

n = input()
b = input()

n = int(n)

list_c = list(range(n))

a = b.split()

p_list = list(itertools.permutations(list_c, 2))
#print(p_list[0][0])
new_list = []

i = 0
for i in range(len(p_list)):
    #print(p_list[i][0])
    #print(p_list[i][1])
    if p_list[i][0]<p_list[i][1]:
        new_list.append(p_list[i])

#print(new_list)
i = 0
result =0
for i in range(n):
    result += int(new_list[i][0]+1)*int(new_list[i][1]+1)

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

Submission status: Runtime Error

Solution code:
import numpy as np
# import sys
# import itertools

N = int(input())
A = np.array(list(map(int, input().split())))
A = A % (1E+9+7)

C = np.array(list(itertools.combinations(A,2)))
# print(C[:,0])
# print(len(C))

answer = np.dot(C[:,0],C[:,1])

# product = 0
# product_sum = 0
# for i in range(len(C)):
#     product = ((C[i][0] % (1E+9+7)) * (C[i][1] % (1E+9+7)))
#     product_sum = product_sum + product
#     product_sum = product_sum % (1E+9+7)

answer = answer % (1E+9+7)
print(int(answer))

Submission status: Runtime Error

Solution code:
n = int(input())
m = 1e9 + 7
a = []
s = 0
r = 0
for _ in range(n):
    x = int(input())
    s += x
    r += x * x
s *= s
ans = (s - r) / 2
ans %= m
print(ans)

Submission status: Runtime Error

Solution code:
def sum_a(array):
    total = 0
    for i in range(len(array)):
        total += array[i]**2
    return(total)

n = int(input())
a = list(map(int,input().split()))
import numpy as np
b = a.copy()

c = np.array(a)
d = np.array(b)

e = np.outer(c,d)

f = np.sum(e)
g = sum_a(a)

print(int((f-g)/2)%(10**9+7))

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
mod = 1000000007
sum = 0
indsum = 0
for i in A:
  sum += i
  sum%=mod
  p = (i*i)%mod
  indsum+=p
  indsum%=mod
squaresum = (sum*sum)%mod
res = (((sumsquare-indsum)%mod)/2)%mod
print(res)

Submission status: Runtime Error

Solution code:
import numpy as np

def main():
  N = int(input(""))
  in2 = input("")
  num_list = np.array([int(x) for x in in2.split(" ")])
  
  i_vector = np.transpose(np.reshape(num_list, (1,N)))
  j_vector = np.triu(num_list, k=1)
  
  print(i_vector)
  print(j_vector)
  sum = np.sum(i_vector * j_vector)

  print(sum % (10**9+7))
 
if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
import numpy as np
m = 10**9 + 7
n = int(input())
an = list(map(int, input().split()))

an_np = np.array(an)
an_col = np.zeros((n-1,n-1))
summary = 0
zero = np.zeros((1,n-1))
for i in range(0, n-1):
    tmp = np.array(an_np[i+1: n])
    an_col[i] = np.append(tmp, zero)[:n-1]

print(int(sum(sum(np.multiply(an_np[:-1], an_col) % m)%m)%m))

Submission status: Runtime Error

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

ans = 1
res = 0

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

for i in range(N):
    res += ans * pow(A[i], -1, 10 ** 9 + 7)
    res %= 10 ** 9 + 7

print(res)

Submission status: Runtime Error

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

import numpy as np

mod = 10**9 + 7

mesh = np.array(np.meshgrid(A, A), dtype=np.int64)
comb = mesh.T.reshape(-1, 2)

t_comb = []
for c in comb:
    if c[0] == c[1]:
        continue
    else:
        t_comb.append(sorted(c))

t_comb = np.unique(t_comb, axis=0)

summa = 0
for c in t_comb:
    summa += c[0] * c[1]

print(summa % mod)

Submission status: Runtime Error

Solution code:
import itertools as it

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

c = list(it.combinations(a, 2))

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

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

Submission status: Runtime Error

Solution code:
from sys import stdin

n = stdin.readline().rstrip().split()[0]
A = [int(x) for x in stdin.readline().rstrip().split()]

s = str(int((sum(A)**2 - sum([a**2 for a in A])) / 2))

if(int(s) < (10**9 + 7)):
    print(int(s))

x = int(s[-9:]) - 7 * int(s[:-9])
if(x < 0):
    print(x + 10**9 + 7)
else:
    print(x)

Submission status: Runtime Error

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

for i in range(1, n):
    ans += li[0]*li[i]

check = ans%mod
for i in range(1, n):
    check -= li[i] * li[i-1]
    if check < 0:
        check += 10**9 + 7
    check //= li[i-1]
    check *= li[i]
    ans += check
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())

A = []

for i in range(N):
  A[i] = int(input())

sum = 0

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

sum %= 1000*1000*1000+7

print(sum)

Submission status: Runtime Error

Solution code:
N = int(input())
A = []
a = int(0)
m = int(1000000007)
n = int(1)

for i in range(N):
    A.append(int(input()))

for i in range(N-1):
    for j in range(N-n):
        a = a + A[i] * A[j + n]
    
    n += 1

print(a % m)

Submission status: Runtime Error

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: Runtime Error

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

for i in range(1, n):
    ans += li[0]*li[i]

check = ans
for i in range(1, n):
    check -= li[i] * li[i-1]
    if check < 0:
        check += 10**9 + 7
    check //= li[i-1]
    check *= li[i]
    ans += check
    ans %= mod

print(ans)

Submission status: Runtime Error

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)%1000000007
  
# Driver code 
if __name__ == '__main__': 
    A = []
    n = int(input())
    for i in range(0,n,1):
        item = float(input())
        A.append(item)
    #print(A)
    print(int(findProductSum(A, n)))

Submission status: Runtime Error

Solution code:
import numpy as np

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

mod = 10**9+7

temp = A*A.T
for i in range(N):
    temp[i,i]=0
temp = np.tril(temp)
temp = temp%mod
temp_sum = np.sum(temp)%mod
temp_sum = np.sum(temp_sum)%mod

print(int(temp_sum))

Submission status: Runtime Error

Solution code:
import numpy as np
N = input()
A = input()

N = int(N)

#
part_A = A.split(" ")
int_A = [float(i) for i in part_A]

part_sum = [sum(int_A[i+1:N]) for i in range(len(int_A)-1)]
sum = np.dot(np.array(part_sum), np.array(int_A[:-1]))

MOD = 1000000007
print(sum0%MOD)

Submission status: Runtime Error

Solution code:
N = int(input())
An = list(map(int, input().strip().split()))
S = 0

for i in range(N):
    for j in range(N-1-i):
        S += S % An[i]*An[N-1-j]%1000000007

print(S)

Submission status: Runtime Error

Solution code:
for i in range (N):
    A = (int(input())
MASS = 0
for i in range (N - 1):
    T = 0
    for j in range (i + 1, N):
        T += (A[j] % NUM)
    MASS += ((A[i]%NUM) * (T%NUM))%NUM
print(MASS % NUM)

Submission status: Runtime Error

Solution code:
def findProductSum(A, n): 

      

 

    array_sum = 0

    for i in range(0, n, 1): 

        array_sum = array_sum + A[i] 

  

Hap



    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: Runtime Error

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 -arrau[i])
print(int(ans/2)%(10**9+7))

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())
a = list(map(int, input().split()))
zenbu = sum(a)
ans = 0

for i in range(n):
  ans += a[i]*(zenbu-a[i])
 
print(ans // 2 % (1000000000+7))

Submission status: Runtime Error

Solution code:
import functools
import operator

N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
ans = 0

for i in range(2**len(A)):\
    list2 = []
    for j in range(len(A)):
        if (i >> j) &1 == 1:
            list2.append(A[j])
    if len(list2) == 2:
        ans += list2[0]*list2[1]
#        print(ans)
#    print(list2)
    ans = ans%mod
print(ans)

Submission status: Runtime Error

Solution code:
def sum_a(array):
    total = 0
    for i in range(len(array)):
        total += array[i]**2
    return(total)

n = int(input())
a = list(map(int,input().split()))
import numpy as np
b = a.copy()
c = np.array(a)
d = np.array(b)

e = np.outer(c,d)

f = np.sum(e)
g = sum_a(a)

print(int(int((f-g)/2)%(10**9+7)))

Submission status: Runtime Error

Solution code:
from itertools import combinations
n = int(input())
li = []
for i in range(0,n):
    a = int(input())
    li.append(a)
comb = combinations(li, 2)
li1 = []
out = []
for i in list(comb):
    li1.append(i)

for j in li1:
    temp = j[0]*j[1]
    out.append(temp)

print(sum(out))

Submission status: Runtime Error

Solution code:
import numpy as np
if __name__ == '__main__':
    n = int(input())
    a = np.array(input().split()).astype(np.int64)

    num = 10**9+7

    mat = np.tril(a.reshape((-1, 1)) * a, k=-1)
    mat %= num
    sum = (np.sum(mat)) % num
    print(sum)

Submission status: Runtime Error

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

ans = 0
for i in range(n-1):
    ans = (ans+(A[i]*sum(A[i+1:])%MOD)%MOD)%MOD
print(ans)

Submission status: Runtime Error

Solution code:
#include <iostream> 
using namespace std; 
  
// required function 
int findProductSum(int A[], int n) {
    int array_sum = 0; 
    for (int i = 0; i < n; i++) 
        array_sum = array_sum + A[i]; 
    int array_sum_square = array_sum * array_sum; 
    int individual_square_sum = 0; 
    for (int i = 0; i < n; i++) 
        individual_square_sum += A[i]*A[i]; 
    return (array_sum_square - individual_square_sum)/2 % 1000000007; 
} 
int n,A[200000+5];
int main() { 	
 	cin >> n;
 	for(int i = 0;  i < n; i++){
    	cin >> A[i];
    }
    int n = sizeof(A)/sizeof(A[0]); 
    cout << findProductSum(A, n); 
    return 0; 
}

Submission status: Runtime Error

Solution code:
import numpy as np

def product(list):
    p = 1
    for i in list:
        p *= i
    return p


n = int(input())
a = list(map(int, input().split()))
sum = 0
for i in range(len(a)-1):
    for j in range(i+1,len(a)):
        sum += a[i]*a[j]
        
ans = np.mod(sum,10**9+7)

print(ans)

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
numbers = np.array(list(map(int, input().split())))
xx, yy = np.meshgrid(numbers, numbers)
times = xx * yy
eye = np.eye(N)
times_sum = np.where(eye == 0, times, 0).sum() / 2
print(int(times_sum % (10**9 + 7)))

Submission status: Runtime Error

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((array_sum_square - individual_square_sum) / 2))
print(result)

Submission status: Runtime Error

Solution code:
# abc177_c.py
from numba import jit
@numba
def solve():
    N = int(input())
    A = list(map(int,input().split()))
    ans = 0
    mod = 10**9+7
    for i in range(N-1):
        for j in range(i+1,N):
            if i != j:
                ans+=A[i]*A[j]
                ans%=mod
    return ans%mod

print(solve())

Submission status: Runtime Error

Solution code:
import numpy as np
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: Runtime Error

Solution code:
N = int(input())
Sum = 0
A = np.array((map(int, input().split())))
for j in range(N):
  for i in range(j):
    Sum += A[i]*A[j]
print(Sum%(1000000000+7))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
using namespace __detail;

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
const int M = 1e9 + 7;

int main()
{
	fast;
	ll n;
	cin >> n;
	vll a(n);
	ll sum = 0;
	FOR(n)
	{
		cin >> a[i];
		// sum = sum + a[i];
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			sum += a[i] * a[j];
		}
	}
	cout << sum % M;
}

Submission status: Runtime Error

Solution code:
sum_all=[]
for i in range(N-1):
    for j in range(i+1,N):
        A[i]=A[i]%mod
        A[j]=A[j]%mod
        sum_all.append((A[i])*(A[j]))

sum=0
for n in sum_all:
    sum+=n
print(sum%mod)

Submission status: Runtime Error

Solution code:
import numpy as np

mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
ans = np.triu(np.outer(a, a), k=1).sum()

print(ans % mod)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
 
#define N 1000005
 
using namespace std;
 
int main(){
    int64_t n,sum=0,l=0;
    cin>>n;
    int64_t a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
        l+=(a[i]*a[i]);
    }
    int64_t result=((sum*sum)-l)/2;
    cout<<result%1000000007<<endl;
    return 0;
}

Submission status: Runtime Error

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

sum = 0

def mod(num):
    if num > 10 ** 9 + 7:
        amari = num % (10 ** 9 + 7)
    return amari

j = 0
while j < n:
    i = 0
    while i < j:
        sum += mod(a_list[i] * a_list[j])
        if sum >= 10 ** 9 + 7:
            sum = sum % (10 ** 9 + 7)
        i += 1
    j += 1

print(sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod_v = 10**9 + 7
    ans = [0] * (N + 1)
    for i in range(0, N - 1):
        ai = A[0]
        aj = A[i + 1]
        ans[0] += ai * aj
    for j in range(1, N - 1):
        ans[j] = (ans[j - 1] - A[j - 1] * A[j]) // A[j - 1] * A[j]
    ret = 0
    for k in range(0, N):
        ret += ans[k]
    ret = ret % mod_v
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

#define N 1000005

using namespace std;

int main(){
    int64_t n,sum=0,l=0;
    cin>>n;
    int64_t a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
        l+=(a[i]*a[i]);
    }
    int64_t result=((sum*sum)-l)/2;
    cout<<abs(result%1000000007)<<endl;
}

Submission status: Runtime Error

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

def func(n):
    if n == 1:
        return 0
    else:
        sum = 0
        for i in range(n-1):
            sum += A[i]
        return func(n-1) + sum * A[n-1]

ans = func(N)
mod = 10 ** 9 + 7
print(ans % mod)

Submission status: Runtime Error

Solution code:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() 
{
    long long int mu=0,su=0,n,i,j;
    long long int c=1000000007;
    scanf("%lld",&n);
    long long int l[n];
    for(i=0;i<n;i++)
    {
        scanf("%lld",&l[i]);
    }
    for(i=0;i<n-1;i++)
    {
        for(j=i+1;j<n;j++)
        {
            mu=( ( l[i] % c ) * ( l[j] % c ) ) % c;
            su= ( ( su % c ) + ( mu % c ) ) % c;
        }
    }
    printf("%lld",su);
}

Submission status: Runtime Error

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod_v = 10**9 + 7
    ans = [0] * (N + 1)
    for i in range(0, N - 1):
        ai = A[0]
        aj = A[i + 1]
        ans[0] += ai * aj
    for j in range(1, N - 1):
        ans[j] = (ans[j - 1] - A[j - 1] * A[j]) // A[j - 1] * A[j]
    ret = 0
    for k in range(0, N):
        ret += ans[k]
    if ret > mod_v:
        ret = ret % mod_v
    print(ret)


if __name__ == '__main__':
    main()