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:
def findProductSum(A, n):
    tmp = (10**9)+7

    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]
        individual_square_sum = individual_square_sum

    return ((array_sum_square - individual_square_sum) / 2) % tmp

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

print(findProductSum(a,n))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a=int((np.sum(A)**2-np.sum(A**2))/2)
print(a%(10**9+7))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a=(np.sum(A)**2-np.sum(A**2))/2
print(int(a%(10**9+7)))

Submission status: Wrong Answer

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

a=(np.sum(A)**2-np.sum(A**2))/2
print(a%(10**9+7))

Submission status: Wrong Answer

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

ans = 0
double = 0

for i in a:
    double += i*i

ans = (sum(a) * sum(a) - double) / 2
print(int(ans%(10**9 + 7)))

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.buffer.readline

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

cumsum = [0]
for i in range(1, N):
    v = (A[0] * A[i]) % MOD
    cumsum.append((cumsum[-1] + v) % MOD)
print(cumsum)

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

Submission status: Wrong Answer

Solution code:
a = input()
import numpy as np
b = list(map(int,input().split()))
b = np.array(b)
m = 10**9 + 7
total = int((sum(b)**2 - b.dot(b))/2)

print(total%m)

Submission status: Wrong Answer

Solution code:
a = input()
import numpy as np
b = list(map(int,input().split()))
b = np.array(b)
m = 10**9 + 7
total = (sum(b)**2 - b.dot(b))/2

print(int(total%m))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
A.sort()
sums = 0
for i in range(n):
  for j in range(n):
    sums += A[i]*A[j]
    
summ = 0
for i in range(n):
  summ += A[i]**2
  
tot = (sums-summ)/2
print(int(tot))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range;R=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def NLI(n):return [[int(i) for i in input().split()] for i in range(n)]
def NLI_(n):return [[int(i)-1 for i in input().split()] for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def RLI(n=8,a=1,b=10):return [random.randint(a,b)for i in range(n)]
def RI(a=1,b=10):return random.randint(a,b)
def Rtest(T):
    case,err=0,0
    for i in range(T):
        inp=INP()
        a1,ls=naive(*inp)
        a2=solve(*inp)
        if a1!=a2:
            print((a1,a2),inp)
            err+=1
        case+=1
    print('Tested',case,'case with',err,'errors')
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
    #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in R(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in R(base**n):s=[tb//(base**bt)%base for bt in R(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
#mo=998244353
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**9)
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

ans=0


n=I()
a=LI()
A=sum(a)%mo
ans=(A*A-sum([i**2 for i in a]))//2
print(ans%mo)

Submission status: Wrong Answer

Solution code:
import itertools
s=1000000009
n=int(input())
a=list(map(int,input().split()))
b=list(itertools.combinations(a,2))
sum=0
for i in b:
  d=i[0]
  e=i[1]
  f=(d*e)%s
  sum+=f
sum=sum%s
print(sum)

Submission status: Wrong Answer

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]

if s % 2 == 0:
  s = s % 2*(10**9 +7)
  s = s/2
else:
  s = (s + 10**9 + 7) % 2*(10**9 + 7)
  s = s/2
 
print(int(s))

Submission status: Wrong Answer

Solution code:
mod = 1000000007
n = int(input())
a = list(map(int,input().split()))
ans = 0
ans += (sum(a)*sum(a))%mod
for i in range(n):
    ans -= (a[i]*a[i])%mod
    if ans < 0:
        ans += mod
ans *= (mod + 1) / 2
ans %= mod
print(int(ans))

Submission status: Wrong Answer

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]

if s % 2 == 0:
  s = s/2 % (10**9 +7)
else:
  s = (s + 10**9 + 7)/2 % (10**9 + 7)
 
print(int(s))

Submission status: Wrong Answer

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]

if s % 2 == 0:
  s = s/2 % 2*(10**9 +7)
else:
  s = (s + 10**9 + 7)/2 % 2*(10**9 + 7)
 
print(int(s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A =list(map(int,input().split()))
sum =0
for i in range(N):
    for j in range(i+1,N):
        sum += A[i]*A[j]
x =sum
a =10**9+7
result =''

while x>0:
    result = str(x % a) + result
    x//=a
    print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def precompute():
    maxAS = 1000000
    eratree = [0] * (maxAS + 10)
    for p in range(2, maxAS + 1):
        if eratree[p]:
            continue
        # p is prime
        eratree[p] = p
        x = p * p
        while x <= maxAS:
            if not eratree[x]:
                eratree[x] = p
            x += p

    import pickle
    pickle.dump(eratree, open("eratree.pickle", "wb"))


def solve(N, AS):
    import pickle
    eratree = pickle.load(open("eratree.pickle", "rb"))
    num_division = 0

    from collections import defaultdict
    count = defaultdict(int)
    for a in AS:
        factors = []
        while a > 1:
            d = eratree[a]
            factors.append(d)
            a //= d
            num_division += 1
        # debug(": ", factors)
        for f in set(factors):
            count[f] += 1

    # debug(": num_division", num_division)
    if any(x == N for x in count.values()):
        return "not coprime"
    if any(x >= 2 for x in count.values()):
        return "setwise coprime"
    return "pairwise coprime"


def main():
    # parse input
    N = int(input())
    AS = list(map(int, input().split()))
    print(solve(N, AS))


# tests
T1 = """
3
3 4 5
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
pairwise coprime
"""

T2 = """
3
6 10 15
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
setwise coprime
"""

T3 = """
3
6 10 16
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
not coprime
"""

T4 = """
3
100000 100001 100003
"""
TEST_T4 = """
>>> as_input(T4)
>>> main()
pairwise coprime
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

if sys.argv[-1] == 'ONLINE_JUDGE':
    precompute()
elif sys.argv[-1] != "DONTCALL":
    import subprocess
    subprocess.call("pypy3 Main.py DONTCALL", shell=True, stdin=sys.stdin, stdout=sys.stdout)
else:
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def precompute():
    maxAS = 1000000
    eratree = [0] * (maxAS + 10)
    for p in range(2, maxAS + 1):
        if eratree[p]:
            continue
        # p is prime
        eratree[p] = p
        x = p * p
        while x <= maxAS:
            if not eratree[x]:
                eratree[x] = p
            x += p

    import pickle
    pickle.dump(eratree, open("eratree.pickle", "wb"))


def solve(N, AS):
    import pickle
    eratree = pickle.load(open("eratree.pickle", "rb"))
    num_division = 0

    from collections import defaultdict
    count = defaultdict(int)
    for a in AS:
        factors = []
        while a > 1:
            d = eratree[a]
            factors.append(d)
            a //= d
            num_division += 1
        # debug(": ", factors)
        for f in set(factors):
            count[f] += 1

    # debug(": num_division", num_division)
    if any(x == N for x in count.values()):
        return "not coprime"
    if any(x >= 2 for x in count.values()):
        return "setwise coprime"
    return "pairwise coprime"


def main():
    # parse input
    N = int(input())
    AS = list(map(int, input().split()))
    print(solve(N, AS))


# tests
T1 = """
3
3 4 5
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
pairwise coprime
"""

T2 = """
3
6 10 15
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
setwise coprime
"""

T3 = """
3
6 10 16
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
not coprime
"""

T4 = """
3
100000 100001 100003
"""
TEST_T4 = """
>>> as_input(T4)
>>> main()
pairwise coprime
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

if sys.argv[-1] == 'ONLINE_JUDGE':
    precompute()
elif sys.argv[-1] != "DONTCALL":
    import subprocess
    subprocess.call("pypy3 Main.py DONTCALL", shell=True)
else:
    main()

Submission status: Wrong Answer

Solution code:
x = 10 ** 9 + 7

n = int(input())
ol = list(map(int, input().split()))
l = [d % x for d in ol]

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

print(ans)

Submission status: Wrong Answer

Solution code:
x = 10 ** 9 + 7

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

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

print(ans % x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mod = 1000000007
s = sum(a) % mod
ans = 0

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

print(ans // 2)

Submission status: Wrong Answer

Solution code:
import copy
mod=10**9+7
def calc(nums,n):
    if n==2:
        return ((nums[0]%mod)*(nums[1]%mod))%mod
    cpy=copy.deepcopy(nums)    
    save=nums[n-2]
    nums[n-2]=nums[n-1]
    for i in range(n-3,-1,-1):
        s=nums[i]%mod
        nums[i]=(save%mod+nums[i+1]%mod)%mod
        save=s%mod
    print(nums)    
    ans=0  
    
    for i in range(n-1):
        ans=((ans%mod)  +  ((cpy[i]%mod)*(nums[i]%mod))%mod)%mod
    return ans       
    





n=int(input())
nums=list(map(int,input().split()))
print(calc(nums,n))

Submission status: Wrong Answer

Solution code:
def main():
    from sys import stdin
    readline = stdin.readline

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

    S1 = sum(A)
    S2 = sum([ int(x**2) for x in A])
 
    total = (( S1 * S1 ) - S2 ) / 2

    sss = 10**9 + 7
    print(int(total % sss))

main()

Submission status: Wrong Answer

Solution code:
def main():
    from sys import stdin
    readline = stdin.readline

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

    Asum = sum(A) ** 2
    A2 = [ int(x**2) for x in A]
 
    total = int(( Asum - sum(A2)) / 2)

    sss = 10**9 + 7
    print(total % sss)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

def main():
    N = int(input())
    A = list(map(int, input().split()))
    s = sum(A) % mod
    ans = s * s % mod
    for a in A: ans = (ans - a * a) % mod
    print((ans // 2) % mod)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import copy
mod=10**9+7
def calc(nums,n):
    if n==1:
        return 0
    if n==2:
        return nums[0]*nums[1]
    cpy=copy.deepcopy(nums)    
    save=nums[n-2]
    nums[n-2]=nums[n-1]
    for i in range(n-3,-1,-1):
        s=nums[i]%mod
        nums[i]=(save%mod+nums[i+1]%mod)%mod
        save=s%mod
    ans=0  
    
    for i in range(n-1):
        ans=((ans%mod)  +  ((cpy[i]%mod)*(nums[i]%mod))%mod)%mod
    return ans       
       





n=int(input())
nums=list(map(int,input().split()))
print(calc(nums,n))

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

Submission status: Wrong Answer

Solution code:
import copy
mod=10**9+7
def calc(nums,n):
    if n==1:
        return 0
    if n==2:
        return nums[0]*nums[1]
    cpy=copy.deepcopy(nums)    
    save=nums[n-2]
    nums[n-2]=nums[n-1]
    for i in range(n-3,-1,-1):
        s=nums[i]%mod
        nums[i]=(save+nums[i+1])%mod
        save=s
    ans=0  
    
    for i in range(n-1):
        ans=((ans%mod)  +  ((cpy[i]%mod)*(nums[i]%mod))%mod)%mod
    return ans       
       





n=int(input())
nums=list(map(int,input().split()))
print(calc(nums,n))

Submission status: Wrong Answer

Solution code:
import copy
mod=10**9+7
def calc(nums,n):
    if n==1:
        return 0
    if n==2:
        return nums[0]*nums[1]
    cpy=copy.deepcopy(nums)    
    save=nums[n-2]
    nums[n-2]=nums[n-1]
    for i in range(n-3,-1,-1):
        s=nums[i]%mod
        nums[i]=(save+nums[i+1])%mod
        save=s
    ans=0  
    print(nums)
    for i in range(n-1):
        ans=((ans%mod)  +  ((cpy[i]%mod)*(nums[i]%mod))%mod)%mod
    return ans       
       





n=int(input())
nums=list(map(int,input().split()))
print(calc(nums,n))

Submission status: Wrong Answer

Solution code:
import copy
mod=(10**9)+7
def calc(nums,n):
    if n==1:
        return 0
    if n==2:
        return nums[0]*nums[1]
    cpy=copy.deepcopy(nums)    
    save=nums[n-2]
    nums[n-2]=nums[n-1]
    for i in range(n-3,-1,-1):
        s=nums[i]%mod
        nums[i]=(save+nums[i+1])%mod
        save=s
    ans=0  
    print(nums)
    for i in range(n-1):
        ans=((ans%mod)  +  ((cpy[i]%mod)*(nums[i]%mod))%mod)%mod
    return ans       
       





n=int(input())
nums=list(map(int,input().split()))
print(calc(nums,n))

Submission status: Wrong Answer

Solution code:
import copy
mod=(10**9)+7
def calc(nums,n):
    if n==1:
        return 0
    if n==2:
        return nums[0]*nums[1]
    cpy=copy.deepcopy(nums)    
    save=nums[n-2]
    nums[n-2]=nums[n-1]
    for i in range(n-3,-1,-1):
        s=nums[i]
        nums[i]=save+nums[i+1]
        save=s
    ans=0  
    print(nums)
    for i in range(n-1):
        ans=((ans%mod)  +  ((cpy[i]%mod)*(nums[i]%mod))%mod)%mod
    return ans       
       





n=int(input())
nums=list(map(int,input().split()))
print(calc(nums,n))

Submission status: Wrong Answer

Solution code:

def main():
    from sys import stdin
    readline = stdin.readline

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

    Asum = sum(A) ** 2
    A2 = [ x**2 for x in A]
 
    total = int(( Asum - sum(A2)) / 2)

    sss = 10**9 + 7
    print(total % sss)

main()

Submission status: Wrong Answer

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

ans = sum(a)**2

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7
total = 0

for i in range(0,n-1):
    x = sum(list1)-sum(list1[:i+1])
    total += list1[i] * x % mod

print(total)

Submission status: Wrong Answer

Solution code:
import copy
mod=10**9+7
def calc(nums,n):
    if n==1:
        return 0
    if n==2:
        return nums[0]*nums[1]
    cpy=copy.deepcopy(nums)    
    save=nums[n-2]
    nums[n-2]=nums[n-1]
    for i in range(n-3,-1,-1):
        s=nums[i]
        nums[i]=save+nums[i+1]
        save=s
    ans=0  
    for i in range(n-1):
        ans=((ans%mod)  +  ((cpy[i]%mod)*(nums[i]%mod))%mod)%mod
    return ans       
       





n=int(input())
nums=list(map(int,input().split()))
print(calc(nums,n))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A_str = input()
A_str_list = A_str.split()
A = np.array([int(A_str_list[i]) for i in range(N)])
sum = 0
mod = 1000000007
res = np.cumsum(A)
# print(res)
for i in range(N):
    sum += np.mod((res[-1]-res[i])*A[i], mod)
print(np.mod(sum, mod))

Submission status: Wrong Answer

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

sumA = sum(A)
S_A = sumA**2
A_diag = 0

for i in range(len(A)):
  A_diag += A[i]*A[i]

ans = (S_A - A_diag)/2
print(int(ans%(10**9+7)))

Submission status: Wrong Answer

Solution code:
import math

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

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

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

ans = math.floor(ans % MOD)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

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

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

ans = ans % MOD
print(math.floor(ans))

Submission status: Wrong Answer

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

sum = 0
for i in range (N):
    sum += A[i]

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

ans = ans % MOD
print(ans)

Submission status: Wrong Answer

Solution code:
def c_sum_of_product_of_pairs(MOD=10**9 + 7):
    import numpy
    N = int(input())
    A = [int(i) for i in input().split()]

    total = sum(A)
    cumsum = [0] + list(numpy.cumsum(A, dtype='int64'))
    return sum([(total - cumsum[i]) * A[i] for i in range(N)]) % MOD

print(c_sum_of_product_of_pairs())

Submission status: Wrong Answer

Solution code:
def c_sum_of_product_of_pairs(MOD=10**9 + 7):
    import numpy
    N = int(input())
    A = [int(i) for i in input().split()]

    total = sum(A)
    cumsum = list(numpy.cumsum(A, dtype='int64'))
    return sum([(total - cumsum[i]) * A[i] for i in range(N)]) % MOD

print(c_sum_of_product_of_pairs())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split(' ')
a = 0
sum = 0
for i in range(1, N):
    sum += int(A[i])
for i in range(N):
    a += int(A[i]) *  sum
    if i < N - 1:
        sum -= int(A[i + 1])
    
print(int(a % (1e9 + 7)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(input_list)

ans = 0
for i in range(N):
  for j in range(i+1,N):
    ans +=  input_list[i]*input_list[j]
print(ans % (10**9+7))

Submission status: Wrong Answer

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

for i in range(N-1):
  for j in range(i+1,N):
    s = s + x[i]*x[j] % 1000000007

print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = list(map(int, input().split()))
ama_a = sum(a_list)
ans = 0
mod = 10**9+7
for i in a_list:
  ans+=i**2
ans = ama_a**2-ans
ans *= (mod+1)/2
ans %= mod
print(int(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = list(map(int, input().split()))
ama_a = sum(a_list)
ans = 0
for i in a_list:
  ans+=i**2
sax = ((ama_a**2-ans)/2)%(10**9+7)
print(int(sax))

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = list(map(int, input().split()))
ama_a = sum(a_list)
ans = 0
for i in a_list:
  ans+=i**2
ans = ((ama_a**2-ans)/2)%(10**9+7)
print(int(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = list(map(int, input().split()))
mod = 10**9+7
ans = 0
for num1 in ls:
    for num2 in ls:
        if num1 < num2:
            ans += num1*num2%mod
print(ans%mod)

Submission status: Wrong Answer

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

ans = 0
sa = sum(a)%mod

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

Submission status: Wrong Answer

Solution code:
import numpy as np

mod = 10**9+7
N = int(input())
A = np.array([int(i) for i in input().split()])

sum = A.sum() % mod

B = np.square(A)
sum2 = B.sum() % mod

ans = (sum**2 - sum2) % mod

if ans%2==1 : ans += mod
ans //= 2
ans %= mod
print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
sum = 0

#二乗和だけは1項ずつ求めてmodをとる
#for x in A:
#  sum += x
#  sum %= (10**9+7)
sum = A.sum() % (10**9+7)

sum2 = 0
#for x in A:
#  sum2 += x*x
#  sum2 %= (10**9+7)
B = np.square(A)
sum2 = B.sum() % (10**9+7)

ans = (sum**2 - sum2) % (10**9+7)
if ans < 0:
  ans += (10**9+7)
ans *= int((10**9+7+1)/2) 
ans %= (10**9+7)
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
sum = 0

#二乗和だけは1項ずつ求めてmodをとる
#for x in A:
#  sum += x
#  sum %= (10**9+7)
sum = A.sum() % (10**9+7)

sum2 = 0
#for x in A:
#  sum2 += x*x
#  sum2 %= (10**9+7)
sum2 = (A**2).sum() % (10**9+7)

ans = (sum**2 - sum2) % (10**9+7)
if ans < 0:
  ans += (10**9+7)
ans *= int((10**9+7+1)/2) 
ans %= (10**9+7)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
num_list = list(map(int, input().split()))

mod = int(1e+9+7)
cumsum_list = np.cumsum(num_list[::-1])[::-1][1:]
score = 0
for i in range(n-1):
    #print(num_list[i], cumsum_list[i])
    score += (num_list[i] * cumsum_list[i])# % mod
    
print(score % mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
num_list = list(map(int, input().split()))

mod = int(1e+9+7)
cumsum_list = np.cumsum(num_list[::-1])[::-1][1:]
score = 0
for i in range(n-1):
    score += (num_list[i] * cumsum_list[i]) % mod
    
print(score % mod)

Submission status: Wrong Answer

Solution code:
mod = 10**9+7
N = int(input())
a = list(map(int, input().split()))
sum_a = 0
sum_a2 = 0
for x in a:
  sum_a += x
  sum_a %= mod
  sum_a2 += x**2
  sum_a2 %= mod

ans = ((sum_a**2 - sum_a2)%mod)//2
print(ans)

Submission status: Wrong Answer

Solution code:
mod = 10**9+7
N = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)%mod
sum_a2 = sum([x**2 for x in a])%mod
ans = ((sum_a**2 - sum_a2)%mod)//2
print(ans)

Submission status: Wrong Answer

Solution code:
mod = 10**9+7
N = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)%mod
sum_a2 = sum([x**2 for x in a])%mod
ans = ((sum_a**2 - sum_a2)%mod)/2
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
a = np.array(a)
sum_a = np.sum(a)
sum_a2 = np.sum(a**2)

ans = (((sum_a*sum_a)-sum_a2)//2)%mod
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int,input().split()))
sums = 0
moder = 1000000007
s=[0 for i in range(N-1)]
s[-1] = As[-1]
for i in range(N-2):
  s[-(i+2)] = s[-(i+1)]+As[-(i-2)]
for i in range(N-1):
  sums+= (As[i]*s[i])%moder
print(sums%moder)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
num_list = list(map(int, input().split()))

mod = 1e+9+7
cumsum_list = np.cumsum(num_list[::-1])[::-1][1:]
score = 0
for i in range(n-1):
    score += (num_list[i] * cumsum_list[i]) % mod
    
print(int(score % mod))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
num_list = list(map(int, input().split()))

mod = 1e+9+7
cumsum_list = np.cumsum(num_list[::-1])[::-1][1:]
score = 0
for i in range(n-1):
    score += num_list[i] * cumsum_list[i] % mod
    
print(int(score % mod))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
num_list = list(map(int, input().split()))

mod = 1e+7+9
cumsum_list = np.cumsum(num_list[::-1])[::-1][1:]
score = 0
for i in range(n-1):
    score += num_list[i] * cumsum_list[i] % mod
    
print(int(score % mod))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
num_list = list(map(int, input().split()))

mod = 1e+7+9
cumsum_list = np.cumsum(num_list[::-1])[::-1][1:]
score = 0
for i in range(n-1):
    score += num_list[i] * cumsum_list[i] % mod
    
print(score % mod)

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 = ans+(A[i]*A[j])%(7+10**9)
print(ans)

Submission status: Wrong Answer

Solution code:
mod = 10 ** 9 + 7
n = int(input())

a_sum = 0
sq_sum = 0
for a in map(int, input().split()):
  a_sum = (a_sum + a) % mod
  sq_sum = (sq_sum + a * a) % mod
print((a_sum * a_sum - sq_sum) % mod // 2)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
l=list(map(lambda z:z**2,a))
x=sum(a)
y=sum(l)
t=(x-y)//2
if t>(10**9+7):
       print(t%(10**9+7))
else:
       print(t)