Harryxun/stf_run huggingface dataset:
n,m = map(int,input().split())
lst = list(map(int,input().split()))
s = 0
total = sum(lst)
for i in range(n):
  if lst[i] >= total/(4*m):
    s += 1
    
if s >= m:
  print('Yes')
else:
  print('No')
        



### FIXED CODE ###

import sys
k = int(input())
lst = [[0]*10 for i in range(10)]
for i in range(10):
  lst[0][i] = 1
l_sum = [9]  


for i in range(1,10):
  s = 0
  for j in range(10):
    if j == 0:
      lst[i][j] = lst[i-1][j] + lst[i-1][j+1]
    elif j == 9:
      lst[i][j] = lst[i-1][j] + lst[i-1][j-1] 
    else:
      lst[i][j] = lst[i-1][j-1] + lst[i-1][j] + lst[i-1][j+1] 
      
    if j !=0:
      s += lst[i][j]
  l_sum.append(s+l_sum[-1])
    

#表を逆から辿っていく、さらに手直し
i = 0
if k < l_sum[0]:
  print(k)
  sys.exit()
else:
  while True:
    if k < l_sum[i]:
      break
    i += 1
  k = k - l_sum[i-1]
   
  ans = []
  for j in reversed(range(0, i+1)):
    
    if j == i:
      p = 1
      while True:
        if k - lst[j][p] <= 0:
          ans.append(p)
          break
        else:
          k -= lst[j][p]
          p += 1
          
    else:
      if p == 0:
        if k <= lst[j][p]:
          ans.append(p)
        else:
          k -= lst[j][p]
          p += 1
          ans.append(p)
          
      elif p == 9:
        if k <= lst[j][p-1]:
          p = p-1
          ans.append(p)
        else:
          k -= lst[j][p-1]
          ans.append(p)
          
      else:
        if k <= lst[j][p-1]:
          p = p-1
          ans.append(p)
        else:
          k -= lst[j][p-1]
          if k <= lst[j][p]:
            ans.append(p)
          else:
            k -= lst[j][p]
            p = p+1
            ans.append(p)
              
l_s = [str(q) for q in ans]
print(''.join(l_s))
# coding: utf-8
mod = 998244353
N, S = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))

dp = [[0 for _ in range(S+2)] for i in range(N+1)]

for k in range(0, N):
  for s in range(0, S+1):
    dp[k+1][s] += 2 * dp[k][s] - dp[k-1][s]
  if S > A[k+1]:
    for s in range(1,S-A[k+1]+1):
      dp[k+1][s+A[k+1]] += dp[k][s] - dp[k-1][s]
  dp[k+1][A[k+1]] += k+1

print(dp[N][S] % mod)

### FIXED CODE ###

# coding: utf-8
import numpy as np
N, S = list(map(int, input().split()))
A = [0]+list(map(int, input().split()))

dt = np.array([[0 for _ in range(S+1)] for x in range(N+1)])

for n in range(1, N+1):
  if A[n] <= S:
    dt[n,A[n]] += n
  if A[n] < S:
    dt[n, A[n]+1:] += dt[n-1,1:S-A[n]+1] - dt[n-2,1:S-A[n]+1]
  dt[n,:] += dt[n-1,:] * 2 - dt[n-2,:]
  dt[n,:] %= 998244353
print(dt[N,S] % 998244353)
k, a = map(int(), input())

if k * 500 >= a:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

k, a = map(int, input().split())
 
if k * 500 >= a:
  print('Yes')
else:
  print('No')
import itertools
N = int(input())
S = [int(input()) for _ in range(N)]
cos = []
for i in list(itertools.product([0,1], repeat=N)):
  ans = 0
  for j in range(N):
    if i[j] == "1":
      ans += S[j]
  if ans%10 != 0:
    cos.append(ans)
print(max(cos))

### FIXED CODE ###

N = int(input())
S = [int(input()) for _ in range(N)]
if sum(S)%10 != 0:
  print(sum(S))
else:
  A = sorted(S)
  for i in A:
    if (sum(S)-i)%10 != 0:
      print(sum(S)-i)
      exit()
  print(0)
s,w = map(int,input().split)

if s<=w:
  print('unsafe')
else:
  print('safe')

### FIXED CODE ###

s,w = map(int,input().split())

if s<=w:
  print('unsafe')
else:
  print('safe')
N = int(input())
node = [[0,i] for i in range(N)]
ab = []
neigh = [[0 for i in range(N)] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
def dfs(neighbor,start,visited,k,c):
    if sum(visited) == N:
        return ans
    for i in range(N):
        if visited[i] == 0 and neighbor[start][i] == 1:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            dfs(neighbor,i,visited,k,c)

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1][0] += 1
    node[bi-1][0] += 1
    neigh[ai-1][bi-1] = 1
    neigh[bi-1][ai-1] = 1
    ab.append([ai-1,bi-1])
c = list(map(int,input().split()))
c.sort(reverse=True)
node.sort(key=lambda x:x[0],reverse=True)
m = max([node[i][0] for i in range(N)])
max_node = [node[i][1] for i in range(N) if node[i][0] == m]

nn = max_node[0]
can = 0
visited[nn] = 1
ans[nn] = max(c)
dfs(neigh,nn,visited,1,c)



ans2 = ' '.join([str(ans[i]) for i in range(N)])


print(sum(c)-max(c))

print(ans2)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
N = int(input())


node = [0 for i in range(N)]
neigh = [[] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1] += 1
    node[bi-1] += 1
    neigh[ai-1].append(bi-1)
    neigh[bi-1].append(ai-1)
c = list(map(int,input().split()))
c.sort(reverse=True)
flag = False
def dfs(neighbor,start):
    global flag
    global k
    if sum(visited) == N:
        return 0

    for i in neighbor[start]:
        
        if visited[i] == 0:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            try:
                dfs(neighbor,i)
            except RuntimeError:
                flag = True
                return 0




m = max(node)
nn = node.index(m)
#nn = [node[i] for i in range(N) if node[i] == m][0]
visited[nn] = 1
ans[nn] = max(c)

dfs(neigh,nn)
"""
if flag:
    print(100)
    print(' '.join([str(i) for i in range(N)]))
    exit()
"""
ans2 = ' '.join([str(ans[i]) for i in range(N)])


print(sum(c)-max(c))
print(ans2)
a = int(input())
b = int(input())
c = int(input())

if a == b + c or b == a + c or c == a + b:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a, b, c = map(int, input().split())

if a == b + c or b == a + c or c == a + b:
  print("Yes")
else:
  print("No")
A = [input().split() for i in range(3)]
N = int(input())
b = list(map(int,input().split()))
A = [[int(v) for v in l] for l in A]
import numpy as np
A = np.array(A)
l = []
for i in range(N):
  if b[i] in A:
    l.append(tuple(nd[0] for nd in np.where(A == b[i])))
if (0, 0) in l and (1, 0) in l and (2, 0) in l:
  print("Yes")
elif (0, 0) in l and (1, 1) in l and (2, 2) in l:
  print("Yes")
elif (0, 1) in l and (1, 1) in l and (2, 1) in l:
  print("Yes")
elif (0, 2) in l and (1, 1) in l and (2, 0) in l:
  print("Yes")
elif (0, 2) in l and (1, 2) in l and (2, 2) in l:
  print("Yes")
elif (0, 0) in l and (0, 1) in l and (0, 2) in l:
  print("Yes")
elif (1, 0) in l and (1, 1) in l and (1, 2) in l:
  print("Yes")
elif (2, 0) in l and (2, 1) in l and (2, 2) in l:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
    
import numpy as np
A = np.array(A)
l = []
for i in range(N):
  if b[i] in A:
    l.append(tuple(nd[0] for nd in np.where(A == b[i])))
if (0, 0) in l and (1, 0) in l and (2, 0) in l:
  print("Yes")
elif (0, 0) in l and (1, 1) in l and (2, 2) in l:
  print("Yes")
elif (0, 1) in l and (1, 1) in l and (2, 1) in l:
  print("Yes")
elif (0, 2) in l and (1, 1) in l and (2, 0) in l:
  print("Yes")
elif (0, 2) in l and (1, 2) in l and (2, 2) in l:
  print("Yes")
elif (0, 0) in l and (0, 1) in l and (0, 2) in l:
  print("Yes")
elif (1, 0) in l and (1, 1) in l and (1, 2) in l:
  print("Yes")
elif (2, 0) in l and (2, 1) in l and (2, 2) in l:
  print("Yes")
else:
  print("No")
x = input()
x = x.split()
x[0] = int(x[0])
x[1] = int(x[1])
 print(x[0]*x[1],x[0]*2+x[1]*2)

### FIXED CODE ###

x = input()
x = x.split()
x[0] = int(x[0])
x[1] = int(x[1])
print(str(x[0]*x[1]),str(x[0]*2+x[1]*2))
N = int(input())
task = []
for i in range(N):
  M = list(map(int,input().split()))
  task.append(M)
task.sort(1)
K = 0
ans = 1
for i in range(N):
  K += task[i,0]
  if (K>task[i,1]):
    ans = 0
    break
if ans:
  print("Yes")
else:
  print("No")
  

### FIXED CODE ###

N = int(input())
task = []
for i in range(N):
  M = list(map(int,input().split()))
  M[0],M[1]=M[1],M[0]
  task.append(M)
task.sort()
K = 0
ans = 1
for i in range(N):
  K += task[i][1]
  if (K>task[i][0]):
    ans = 0
    break
if ans:
  print("Yes")
else:
  print("No")
four = input()

four = sorted(four)
if four[1] = four[2] and four[3] = four[4] and four[2] != four[3]:
	print ("Yes")
else:
	print("No")

### FIXED CODE ###

S = list(input())
 
S = sorted(S)
 
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print('Yes')
else:
    print('No')
from collections import deque, Counter, defaultdict
from functools import lru_cache
from itertools import permutations
from heapq import (
    heappush,
    heappop,
    heapreplace,
    heappushpop,
    heapify,
    merge,
    nlargest,
    nsmallest,
)
from statistics import mean, median, mode


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    return a * b // gcd(a, b)


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

clcm = 1
for num in a:
    clcm = lcm(clcm, num)

tot = 0
for num in a:
    tot += clcm // num

print(int(tot % (1e9 + 7)))


### FIXED CODE ###

def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)

def lcm(a,b):
  return a * b // gcd(a,b)

n = int(input())
av = list(map(int, input().split(' ')))
alcm = 1
for i in av:
  alcm = lcm(alcm, i)

tot = 0
for i in range(n):
  tot += alcm // av[i]

print(tot % 1000000007)
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    N,K = LI()
    a = LI()
    if max(a) < K:
        return 'IMPOSSIBLE'
    if K in a:
        return 'POSSIBLE'
    t = a[0]
    for i in range(1,N):
        t = math.gcd(a[i], t)
    if t <= 1:
        return 'POSSIBLE'
    for c in a:
        if (c > K) and (((c-K) % t) == 0):
            return 'POSSIBLE'

    return 'IMPOSSIBLE'


print(main())





### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def gcd(a,b):
    while b>0:
        a,b = b,a
        b %= a
    return a

def main():
    N,K = LI()
    a = LI()
    if max(a) < K:
        return 'IMPOSSIBLE'
    if K in a:
        return 'POSSIBLE'
    t = a[0]
    for c in a[1:]:
        t = gcd(c, t)
        if t <= 1:
            return 'POSSIBLE'
    for c in a:
        if (c > K) and (((c-K) % t) == 0):
            return 'POSSIBLE'

    return 'IMPOSSIBLE'


print(main())
n, k = map(int, input().split())
stones = list(map(int, input.split()))

dp = [False for _ in range(k+1)]

for i in range(k+1):
  for j in stones:
    if i >= j and dp[i-j] == False:
      dp[i] = True
      continue
      
if dp[k]:
  print('First')
else:
  print('Second')

### FIXED CODE ###

n, k = map(int, input().split())
stones = list(map(int, input().split()))

dp = [False for _ in range(k+1)]

for i in range(1, k+1):
  for j in stones:
    if i >= j and dp[i-j] == False:
      dp[i] = True
      continue
      
if dp[k]:
  print("First")
else:
  print("Second")
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string S[3];
int N;

for(i=0; i<N; i++) cin >> S[i];
if(S[0] == S[1] == S[2]);
  print("Yes")
else;
  print("No)


### FIXED CODE ###

S = input()
if(S[0] == S[1] and S[1] == S[2]):
  print("No")
 
else:
  print('Yes')
n,m=map(int,input().split())
def C(n, r ,mod=10**9+7):
    if n-r<r: r=n-r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k]) %mod

    return result % mod
print(C(a+1,b))

### FIXED CODE ###

import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal as D  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
from fractions import Fraction as F  #F(a,b)で正確なa/b
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

a,b=map(int,input().split())
if abs(a-b)>=2:
    print(0)
    exit()
mod=10**9+7
re=2 if a==b else 1
def kaijou(n):
    if n==1:return 1
    else:
        return (kaijou(n-1)*n)%mod


print(kaijou(a)*kaijou(b)*re%mod)
x,y,z = int(input().split())
int D=int x
int T=int y
int S=int z

if T-D/S>= 0:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

D,T,S = map(int, input().split())

if T-D/S >= 0:
    print("Yes")
else:
    print("No")
N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A = [[] for _ in range(N)]

for edge in edges:#edge0=u,edge1=v,edge2=w
  u=edge[0]
  v=edge[1]
  w=edge[2]
  A[u-1].append([v-1,w])
  A[v-1].append([u-1,w])
#A[i-1]に頂点iと隣接する頂点とその距離を格納

#depth[i-1]=頂点１から頂点iへの距離
#頂点1への距離は0
depth = [-1] * (N)
depth[1] = 0
#depth[i] = 1から頂点dまでの距離(=depth[d]) + 頂点dからiの距離(=X[1]))で更新可能

def dfs(A,d):
    for X in A[d]:#X[0]:頂点X　X[1]:頂点dから頂点Xの距離
        if depth[X[0]] == -1:#距離が-1ならまだ行っていない
            depth[X[0]] = depth[d] + X[1]
            dfs(A,X[0])#次の隣の頂点へ

dfs(A,0)#頂点0からスタート
for d in depth:
    if d % 2 == 0:
        print(0)
    else:
        print(1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(500*500)
N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A = [[] for _ in range(N+1)]
 
for edge in edges:
  A[edge[0]].append([edge[1],edge[2]])
  A[edge[1]].append([edge[0],edge[2]])
  
depth = [-1] * (N+1)
depth[1] = 0
 
def dfs(A,s):
  for v in A[s]:
    if depth[v[0]] == -1:
      depth[v[0]] = depth[s] + v[1]
      dfs(A,v[0])    
dfs(A,1)
for d in depth[1:]:
  if d % 2 == 0:
    print(0)
  else:
    print(1)
A, B, K =map(int, input().split())
if K<A:
    A_after=A-K
elif K>=A:
    A_after=0
    if K-A<B:
            B_after=B-(K-A)
        elif K-A>=B:
            B_after=0
print(A_after, B_after)

### FIXED CODE ###

A, B, K =map(int, input().split())
if K<A:
    A_after=A-K
    B_after=B
elif K>=A:
    A_after=0
    if K-A<B:
        B_after=B-(K-A)
    elif K-A>=B:
        B_after=0
print(A_after, B_after)
# https://atcoder.jp/contests/abc148/tasks/abc148_c
import fractions
# math.gcdは3.5からなのでAtCoderで使えない
# import math


def main():
    (a, b) = [int(i) for i in input().split(" ")]
    print(int(a * b / fractions.gcd(a, b)))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# https://atcoder.jp/contests/abc148/tasks/abc148_a


def main():
    ans = [1,2,3]
    a = int(input())
    b = int(input())
    ans.remove(a)
    ans.remove(b)
    print(ans[0])


if __name__ == '__main__':
    main()
n,m=map(int,input().split())
l=[list(map(int,input().split()))[0] for i in range(m)]
r=[list(map(int,input().split()))[1] for i in range(m)]
lm=max(l)
mr=min(r)
x=mr-lm+1

if x>=:
  print(x)
else:
  print(0)

### FIXED CODE ###

n,m=map(int,input().split())
lm,mr=0,n
for i in range(m):
  l,r=map(int,input().split())
  lm=max(lm,l)
  mr=min(mr,r)
  x=mr-lm+1

if x>=0:
  print(x)
else:
  print(0)
N = int(input())
A = list(map(int,input().split()))

A.sort()
n = A[-1]

r_=11/2

a_before=''
for a in A[:-1]:
    if a >= r_:
        break
    a_before = a
    
if abs(r_-a) >= abs(r_-a_before):
    r = a_before
else:
    r = a
    
print(n,r)

### FIXED CODE ###

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

A.sort()
n = A[-1]

r_=n/2

a_before=''
for a in A[:-1]:
    if a >= r_:
        break
    a_before = a
    
if abs(r_-a) >= abs(r_-a_before):
    r = a_before
else:
    r = a
    
print(n,r)
def factors(n):    
    return set(reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))

def prime(n1):
	for i in range(2, int(math.sqrt(n1))+1):
		if n1%i == 0:
			return False
	return True

n = int(input())
if prime(n):
	print(n - 1)
else:
	k = sorted(list(factors(n)))
	#print(k)
	if len(k) %2 != 0:
		if k[len(k)//2]*k[len(k)//2] == n:
			print(2*k[len(k)//2] - 2)
		#else:

	else:
		s = k[len(k)//2 - 1] + k[len(k)//2]
		print(s - 2)


### FIXED CODE ###

import math
from functools import reduce

def factors(n):    
    return set(reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))

def prime(n1):
	for i in range(2, int(math.sqrt(n1))+1):
		if n1%i == 0:
			return False
	return True

n = int(input())
if prime(n):
	print(n - 1)
else:
	k = sorted(list(factors(n)))
	#print(k)
	if len(k) % 2 != 0:
		if k[len(k)//2]*k[len(k)//2] == n:
			print(2*k[len(k)//2] - 2)
		#else:

	else:
		s = k[len(k)//2 - 1] + k[len(k)//2]
		print(s - 2)
nums1 = list(map(int,input().split()))
nums2 = list(map(int,input().split()))
nums3 = list(map(int,input().split()))
seen = [nums1[0],nums1[1],nums1[2],nums2[0],nums2[1],nums2[2],nums3[0],nums3[1],nums3[2]]
over = False
N = int(input())
for x in range(N):
  num = int(input())
  if num in seen:
    seen[x] = "O"
if seen[0] == "O":
  if seen[1] == seen[2] == "O":
    print("YES")
    over = True
  elif seen[3] == seen[6] == "O":
    print("YES")
    over = True
  elif seen[4] == seen[8] == "O":
    print("YES")
    over = True
elif seen[2] == "O":
  if seen[5] == seen[8] == "O":
    print("YES")
    over = True
  elif seen[4] == seen[6] == "O":
    print("YES")
    over = True
elif seen[8] == "O" == seen[7] == seen[6]:
  print("YES")
  over = True
elif seen[3] == seen[4] == seen[5] == "O":
  print("YES")
  over = True
elif seen[1] == seen[4] == seen[7] == "O":
  print("YES")
  over = True
else:
  print("NO")
if not over:
  print("YES")

### FIXED CODE ###

seen = [0,0,0,0,0,0,0,0,0]
seen[0],seen[1],seen[2] = (map(int,input().split()))
seen[3],seen[4],seen[5] = (map(int,input().split()))
seen[6],seen[7],seen[8] = (map(int,input().split()))
over = "No"
N = int(input())
for x in range(N):
  num = int(input())
  if num in seen:
    seen[seen.index(num)] = "O"
if seen[0] == "O":
  if seen[1] == "O" and seen[2] == "O":
    over = "Yes"
  if seen[3] == "O" and seen[6] == "O":
    over = "Yes"
  if seen[4] == "O" and seen[8] == "O":
    over = "Yes"
if seen[8] == "O":
  if seen[6] == "O" and seen[7] == "O":
    over = "Yes"
  if seen[2] == "O" and seen[5] == "O":
    over = "Yes"
if seen[4] == "O":
  if seen[6] == "O" and seen[2] == "O":
    over = "Yes"
  if seen[1] == "O" and seen[7] == "O":
    over = "Yes"
  if seen[3] == "O" and seen[5] == "O":
    over = "Yes"
print(over)
mod = 10 ** 9 + 7
n = int(input())
a_list = list(map(int, input().split()))
result = 0
a_sum = sum(a)
for i in a_list:
    a_sum -= i
    result += i * a_sum
print(result % mod)

### FIXED CODE ###

mod = 10 ** 9 + 7
n = int(input())
a_list = list(map(int, input().split()))
result = 0
a_sum = sum(a_list)
for i in a_list:
    a_sum -= i
    result += i * a_sum
print(result % mod)
n,m = map(int,input().split())
a = list(int(input()) for hoge in range(m))
dan = [a[0]]
ans = 1
for i in range(m-1):
         if (a[i+1]-(a[i]+1)) == 0:
                  print(0)
                  exit()
         dan.append(a[i+1]-(a[i]+1))
dan.append(n-(a[m-1]))
for j in range (len(dan)):
         ans *= ((2 ** (dan[j] //2)))
print(ans%((10 ** 9) +7))



### FIXED CODE ###

n,m = map(int,input().split())
a = [int(input()) for i in range(m)]
step_patern = [0,1]
for i in range(n):
         step_patern.append(step_patern[i] + step_patern[i+1])
kankaku = []
tmp = 0
for i in range(len(a)):
         kankaku.append(a[i] - tmp)
         tmp = a[i] +1
kankaku.append(n + 1 - tmp)
ans = 1
for i in kankaku:
         ans *= step_patern[i]
         ans %= (10 ** 9) +7
print(ans)
k,x = map(int.input(),split())
if x <= k :
    print('Yes')
else :
    print('No')

### FIXED CODE ###

k,x = map(int,input().split())
if x <= 500*k :
    print('Yes')
else :
    print('No')
N = int(input())
if(N % 10 == 0 or N % 10 == 1 N % 10 == 6 N % 10 == 8):
  print("pon")
elif(N % 10 == 3):
  print("bon")
else:
  print("hon")

### FIXED CODE ###

N = int(input())
if(N % 10 == 0 or N % 10 == 1 or N % 10 == 6 or N % 10 == 8):
  print("pon")
elif(N % 10 == 3):
  print("bon")
else:
  print("hon")
S = input()
if S is "ABC":
  print("ARC)
else:print("ABC")

### FIXED CODE ###

S=input()
if S == "ABC":print("ARC")
else : print("ABC")
a,b = map(int, input().split(" "))
list_a = [i for i in range(round(a/0.08+0.5)-1, round((a+1)/0.08 +0.5))]
list_b = [i for i in range(round(b/0.1 +0.5)-1,round((b+1)/0.1 +0.5))]
list_and = list(set(list_a) & set(list_b))
if list_and == []:
    print("-1")
else:
    print(min(list_and))

### FIXED CODE ###

a = input()
if ("B" in a) & ("A" in a):
    print("Yes")
else:
    print("No")
a,b,c=map(int,input().split())
if (a,b)==(0,0):
  print(a,b)
  exit(0)
if(a-k<0):
  print max(0,k-(b-a))
else:
        print(a,b)


### FIXED CODE ###

a, b, k = map(int, input().split())
if (a, b) == (0, 0):
    print(0, 0)
    exit(0)
if a - k < 0:
    print(0, max(0, b - (k-a)))
else:
    print(a-k, b)
x=0
for _ in range(int(input())):
    o,y=map(int,input().split())
    if o==1:x+=y
    elif o==2:x-=y
    elif o==3:x*=y
    else:x/=y
print(int(x))

### FIXED CODE ###

m=10000000019
x=0
def mod(x):return (x%m+m)%m
def pow(x,a):
    ret=1
    while a:
        if(a&1):ret=mod(x*ret)
        x=mod(x*x)
        a>>=1
    return ret

for _ in range(int(input())):
    o,y=map(int,input().split())
    if o==1:x=(x+y)%m
    elif o==2:x=(x-y)%m
    elif o==3:x=mod(x*y)
    else:x=mod(x*pow(y,m-2))
print(x if x<(1<<31)else x-m)
import numpy as np
N = int(input())
m = np.zeros((N + 1, N + 1), dtype='int32')
for _ in range(N - 1):
    u, v = sorted(map(int, input().split()))
    np.add(m[:u + 1, v:], 1,out=m[:u + 1, v:])
ans = 0
for L in range(1, N + 1):
    for R in range(L, N + 1):
        ans += R - L + 1 - m[L, R]
print(ans)


### FIXED CODE ###

N = int(input())
M = 0
for _ in range(N - 1):
    u, v = sorted(map(int, input().split()))
    M += u * (N - v + 1)
V = 0
for r in range(1, N + 1):
    V += r * (N - r + 1)
print(V - M)
n, k = map(int, input().split())
mod = 10**9 + 7
s = [0 for i in range(k+1)]
ret = 0

for i in range(k, 0, -1):
    p = int(k/i)
    f = pow(p, n, mod)
    for j in range(2, k+1):
        if i*j <= k:
            c -= s[i*j]
        else:
            break
    
    s[i] = c%mod

    ret = (ret + (c%mod)*i)%mod

print(ret)

### FIXED CODE ###

n, k = map(int, input().split())
mod = 10**9 + 7
s = [0 for i in range(k+1)]
ret = 0

for i in range(k, 0, -1):
    p = int(k/i)
    c = pow(p, n, mod)
    for j in range(2, k+1):
        if i*j <= k:
            c -= s[i*j]
        else:
            break
    
    s[i] = c%mod

    ret = (ret + (c%mod)*i)%mod

print(ret)