Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n = int(input())

a = (list(map(int, input().split())))
dx = 10 ** 9 + 7

b = [i % dx for i in a]

ans = 0
alist = []
for i in range(n):
    for j in range(i+1, n):
        alist.append((b[i] * b[j]) % dx)

ans = sum(alist)
ans %= dx
print(ans)


### FIXED CODE ###

n = int(input())

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

S = sum(a)

S2 = sum(map(lambda x: x * x, a ))

ans = (S * S - S2) // 2 % 1000000007
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N, M = map(int, input().split())
    L = [0] * M
    R = [0] * M
    for i in range(M):
        L[i], R[i] = map(int, input().split())

    ans = N
    for i in range(N):
        for j in range(M):
            c = 0
            if not L[j] <= i + 1 <= R[j]:
                ans -= 1
                c = 1
            if c == 1:
                break
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N, M = map(int, input().split())
    L = [0] * M
    R = [0] * M
    for i in range(M):
        L[i], R[i] = map(int, input().split())

    ans = min(R) - max(L) + 1
    print(max(0, ans))

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import numpy as np
n = int(input())
a = [int(i) for i in input().split()] 
ls = np.array(a)

st = int(n/2)
ans = list(np.where(ls[st:]==1)[0] + 1 + st)
for ind in range(st, 0, -1):
    tmp = list(range(2*ind-1, n, ind))
    s = ls[tmp].sum()%2
    if a[ind-1] == s:
        ls[ind-1] = 0
    else:
        ls[ind-1] = 1
        ans.append(ind)
        
print(sum(ls))
print(' '.join(map(str, ans)))

### FIXED CODE ###

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

st = int(n/2)
ans =  [i+st+1 for i, n in enumerate(a[st:]) if n ==1] 
for ind in range(st, 0, -1):
    tmp = [ls[i] for i in range(2*ind-1, n, ind)]
    s = sum(tmp)%2
    if a[ind-1] == s:
        ls[ind-1] = 0
    else:
        ls[ind-1] = 1
        ans.append(ind)
        
print(sum(ls))
print(' '.join(map(str, ans)))
### BUGGY CODE ###

import numpy as np

H, W = [int(item) for item in input().split()]

grid = np.array([[item for item in input()] for _ in range(H)])
dp = np.zeros((H, W), dtype='int32')

dp[0,0] = 1

for i in range(H):
    for j in range(W):
        if grid[i, j] == '.' and i > 0 and j > 0:
            dp[i, j] = (dp[i-1, j] + dp[i, j-1]) % (10**9 +7)
        elif grid[i, j] == '.' and i == 0 and j > 0:
            dp[i, j] = dp[i, j - 1] % (10**9 +7)
        elif grid[i, j] == '.' and j == 0 and i > 0:
            dp[i, j] = dp[i-1, j] % (10**9 +7)

# print(dp)
print(dp[H-1,W-1])

### FIXED CODE ###

H, W = [int(item) for item in input().split()]
grid = [[item for item in input()] for _ in range(H)]

dp = [[0 for _ in range(W+1)] for _ in range(H+1)]
max_num = 10**9 +7

def main():
    dp[0][1] = 1

    for i in range(H):
        for j in range(W):
            if grid[i][j] != '#':
                dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % max_num
            

    # print(dp)
    print(dp[H][W])

if __name__ == "__main__":
    main()
### BUGGY CODE ###

r1,c1,r2,c2=map(int,input().split())

mod=10**9+7
f=[1]
for i in range(2*10**6+7):f+=[f[-1]*(i+1)%mod]
def comb(a,b):return f[a]*pow(f[b],mod-2,mod)*pow(f[a-b],mod-2,mod)%mod

def F(r,c):
  ans=pow(2,r+c+1,mod) -1
  d=0
  s=0
  for i in range(r-1,-1,-1):
    s+=comb((r-i-1)+c,c)
    d+=pow(2,i,mod)*s
    s%=mod
    d%=mod
  ans=(ans+(mod-d))%mod
  d=0
  s=0
  for i in range(c-1,-1,-1):
    s+=comb((c-i-1)+r,r)
    d+=pow(2,i,mod)*s
    s%=mod
    d%=mod
  ans=(ans+(mod-d))%mod
  
  return ans

ans=F(r2,c2)
ans=(ans+(mod-F(r2,c1-1)))%mod
ans=(ans+(mod-F(r1-1,c2)))%mod
ans+=F(r1-1,c1-1)
print(ans%mod)


### FIXED CODE ###


p = 10**9+7
kai_ = [1]
for i in range(1, 10 ** 7):
    kai_.append(kai_[-1] * i % p)


def kai(x):
    return kai_[x]


def comb(a, b):
    if a < 0 or b < 0:
        return 0
    elif a < b:
        return 0
    c = 1
    c *= kai(a)
    c *= pow(kai(b), p - 2, p)
    c *= pow(kai(a - b), p - 2, p)
    return c % p


r1, c1, r2, c2 = [int(i) for i in input().split()]


def s(r, c):
    return comb(r+c+2,r+1)


print((s(r2, c2) - s(r2, c1 - 1) - s(r1 - 1, c2) + s(r1 - 1, c1 - 1)) % p)
### BUGGY CODE ###

def change(S):
    for i in range(len(S)-1):
        if S[i] == "B" and S[i+1] == "W":
            ans = S[:i] + "WB" + S[i+1+1:]
            break
    return ans


S = input()

count = 0
while "BW" in S:
    S = change(S)
    count += 1

print(count)



### FIXED CODE ###

S = input()

count = 0
countB = 0
for i in range(len(S)):
    if S[i] == "B":
        countB += 1
    else:
        count += countB

print(count)
### BUGGY CODE ###

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

for i in range(N):
    kari = A[i]
    A[i] = 0
    print(max(A))
    A[i] = kari

### FIXED CODE ###

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

MAX_1 = max(A)
MAX_2 = sorted(A)[-2]

for i in range(N):
    if A[i] == MAX_1:
        print(MAX_2)
    else:
        print(MAX_1)
### BUGGY CODE ###

li = []
for _ in range(int(input())):
    c, s = input().split()
    if c == "insert":
        li.append(s)
    elif c == "find":
        print("yes" if s in li else "no")


### FIXED CODE ###

import sys
readline = sys.stdin.readline
SET = set()
input()
for s in sys.stdin:
    if s[0] == "i":
        SET.add(s[7:])
    elif s[0] == "f":
        print("yes" if s[5:] in SET else "no")
### BUGGY CODE ###

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

import numpy as np

ans = []
for i in range(N):
    tmp = np.argmin(nums)
    ans.append(tmp+1)
    nums[tmp] = 10**10
print(*ans)

### FIXED CODE ###

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

ans = [0] * N 

for i, num in zip(range(1, N+1), nums):
    ans[num-1] = i
print(*ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100001)

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
visited = [False] * n
for _ in range(m):
    a, b = map(int, input().split())
    la = len(edges[a - 1])
    lb = len(edges[b - 1])
    edges[a - 1].append([b - 1, lb])
    edges[b - 1].append([a - 1, la])

def dfs(p, v):
    visited[v] = True
    for (i, r) in edges[v]:
        if not visited[i] and r != -1 and i != p:
            dfs(v, i)
    count = 0
    pr = -1
    for (i, r) in edges[v]:
        if i != p:
            if r != -1:
                print(v + 1, i + 1)
                edges[i][r][1] = -1
                count += 1
        else:
            pr = r
    if count % 2 == 1:
        print(v + 1, p + 1)
        edges[p][pr][1] = -1

if m % 2 == 1:
    print(-1)
else:
    dfs(-1, 0)


### FIXED CODE ###

import sys
sys.setrecursionlimit(100001)

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
visited = [False] * n
for _ in range(m):
    a, b = map(int, input().split())
    la = len(edges[a - 1])
    lb = len(edges[b - 1])
    edges[a - 1].append([b - 1, lb])
    edges[b - 1].append([a - 1, la])

def dfs(p, v):
    visited[v] = True
    for (i, r) in edges[v]:
        if not visited[i] and r != -1 and i != p:
            dfs(v, i)
    odd = False
    pr = -1
    for (i, r) in edges[v]:
        if i != p:
            if r != -1:
                edges[i][r][1] = -1
                odd = not odd
        else:
            pr = r
    if odd:
        edges[p][pr][1] = -1

if m % 2 == 1:
    print(-1)
else:
    dfs(-1, 0)
    for v in range(n):
        for (i, r) in edges[v]:
            if r >= 0:
                print(v + 1, i + 1)
### BUGGY CODE ###

from collections import defaultdict, deque

def main():
    H, W = map(int, input().split())
    ch, cw = map(int, input().split())
    dh, dw = map(int, input().split())
    ch -= 1
    cw -= 1
    dh -= 1
    dw -= 1
    maze = [input() for _ in range(H)]

    INF = 10**12
    path = [[INF] * W for _ in range(H)] # 各マスへの移動コスト
    
    # walk:移動A, warp:移動B
    walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

    q = deque()
    path[ch][cw] = 0
    q.append((ch, cw, 0))

    while q:
        x, y, s = q.popleft()
        for dx, dy in walk: #移動A
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == "." and path[nx][ny] > s:
                path[nx][ny] = s
                q.append((nx, ny, s)) # なぜleft?

        for dx, dy in warp: #移動B
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == "." and path[nx][ny] > s + 1:
                path[nx][ny] = s + 1
                q.append((nx, ny, s+1)) # なぜright?

    ans = path[dh][dw] if path[dh][dw] != INF else "-1"
    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import defaultdict, deque

def main():
    H, W = map(int, input().split())
    ch, cw = map(int, input().split())
    dh, dw = map(int, input().split())
    ch -= 1
    cw -= 1
    dh -= 1
    dw -= 1
    maze = [input() for _ in range(H)]

    INF = 10**12
    path = [[INF] * W for _ in range(H)] # 各マスへの移動コスト
    
    # walk:移動A, warp:移動B
    walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

    q = deque()
    path[ch][cw] = 0
    q.append((ch, cw, 0))

    while q:
        x, y, s = q.popleft()
        for dx, dy in walk: #移動A
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == "." and path[nx][ny] > s:
                path[nx][ny] = s
                q.appendleft((nx, ny, s)) # なぜleft?

        for dx, dy in warp: #移動B
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == "." and path[nx][ny] > s + 1:
                path[nx][ny] = s + 1
                q.append((nx, ny, s+1)) # なぜright?

    ans = path[dh][dw] if path[dh][dw] != INF else "-1"
    print(ans)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)
l = -1
r = 10 ** 13
while r - l > 1:
  m = (l + r) // 2
  if sum([(a - m // f) if a * f > m else 0 for a, f in zip(A, F)]) <= k:
    r = m
  else:
    l = m
    
print(r)

### FIXED CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)
l = -1
r = 10 ** 13
while r - l > 1:
  m = (l + r) // 2
  if sum([(a - m // f) if a * f > m else 0 for a, f in zip(A, F)]) <= k:
    r = m
  else:
    l = m
    
print(r)
### BUGGY CODE ###

from math import factorial
def comb(n,r):
  return factorial(n)//factorial(n-r)//factorial(r)
S=input()
N=len(S)
mod=[0 for i in range(2019)]
s=0
for i in range(N-1,-1,-1): 
  s+=int(S[i])*(10**(N-1-i))
  mod2=s%2019
  mod[mod2]+=1
ans=0
for i in range(2019):
  k=mod[i]
  if i==0:
    if k>=2:
      ans+=comb(k,2)+k
    else:
      ans+=k
  else:
    if k>=2:
      ans+=comb(k,2)
print(ans)  

### FIXED CODE ###

import numpy as np
S=input()
N=len(S)
mod=[0 for i in range(2019)]
mod2=0
ten=1
for i in range(N-1,-1,-1): 
  s=int(S[i])*ten
  mod2+=np.mod(s,2019)
  mod2=np.mod(mod2,2019)
  mod[mod2]+=1
  ten=(ten*10)%2019
ans=0
for i in range(2019):
  k=mod[i]
  if i==0:
    if k>=2:
      ans+=k*(k-1)//2+k
    else:
      ans+=k
  else:
    if k>=2:
      ans+=k*(k-1)//2
print(ans)
### BUGGY CODE ###

import sys
def input():
	return sys.stdin.readline()[:-1]

from fractions import gcd
n, m = map(int, input().split())
a = list(map(int, input().split()))
m *= 2

if n == 1:
	print((m//a[0]+1)//2)
else:
	lcm = a[0]*a[1]//gcd(a[0], a[1])
	for i in range(2, n):
		lcm = lcm * a[i] // gcd(lcm, a[i])

	divs = 0
	for x in a:
		divs += (lcm//x)%2
	if divs < n:
		print(0)
	else:
		print((m//lcm+1)//2)

### FIXED CODE ###

import sys
def input():
	return sys.stdin.readline()[:-1]

from fractions import gcd
n, m = map(int, input().split())
a = list(map(int, input().split()))
m *= 2

if n == 1:
	print((m//a[0]+1)//2)
else:
	lcm = a[0]*a[1]//gcd(a[0], a[1])
	for i in range(2, n):
		lcm = lcm * a[i] // gcd(lcm, a[i])
		if lcm > m:
			print(0)
			sys.exit()

	divs = 0
	for x in a:
		divs += (lcm//x)%2
	if divs < n:
		print(0)
	else:
		print((m//lcm+1)//2)
### BUGGY CODE ###

import math
K=int(input())
def gcd(a,b,c):
    s=math.gcd(a,b)
    s=math.gcd(s,c)
    return s
t=0
for a in range(K):
    for b in range(K):
        for c in range(K):
            t+=gcd(a+1,b+1,c+1)
print(t)

### FIXED CODE ###

import math
K=int(input())
def gcd(a,b,c):
    s=math.gcd(a,b)
    s=math.gcd(s,c)
    return s
t=0
for a in range(K):
    for b in range(K):
        s=math.gcd(a+1,b+1)
        for c in range(K):
            t+=math.gcd(c+1,s)
print(t)
### BUGGY CODE ###

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

s_a = set(a)
c_a = []
for i in s_a:
    c_a.append(a.count(i))
d_a = list(zip(s_a, c_a))

ans = 0
for i in d_a:
    if i[0] > i[1]:
        ans += i[1]
    if i[1] > i[0]:
        ans += i[1] - i[0]

print(ans)

### FIXED CODE ###

from collections import Counter

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

ans = 0
for i in c:
    if i > c[i]:
        ans += c[i]
    if c[i] > i:
        ans += c[i] - i

print(ans)
### BUGGY CODE ###

# D - 2017-like Number
# https://atcoder.jp/contests/abc084/tasks/abc084_d

prime = []
is_prime = []
is_prime.append(False)
is_prime.append(False)

def sieve(r):
    for i in range(2, r + 1):
        is_prime.append(True)

    for i in range(2, r + 1):
        if is_prime[i]:
            prime.append(i)

            j = 2 * i
            while j <= r:
                is_prime[j] = False
                j = j + i

def main():
    Q = int(input())
    querys = []
    max_r = 0
    for i in range(Q):
        l, r = map(int, input().split())
        querys.append((l, r))
        if max_r < r:
            max_r = r

    sieve(max_r)

    for l, r in querys:
        like_numbers = [n for n in prime if n % 2 == 1 and l <= n <= r and is_prime[(n + 1) // 2]]
        print(len(like_numbers))
    
main()

### FIXED CODE ###

# D - 2017-like Number
# https://atcoder.jp/contests/abc084/tasks/abc084_d

counts = []
counts.append(0)
counts.append(0)
counts.append(0)

prime = []

is_prime = []
is_prime.append(False)
is_prime.append(False)

def sieve(r):
    for i in range(2, r + 1):
        is_prime.append(True)

    for i in range(2, r + 1):
        if is_prime[i]:
            prime.append(i)

            j = 2 * i
            while j <= r:
                is_prime[j] = False
                j = j + i

def calc_like_number_count(r):
    for i in range(3, r + 1):
        if i % 2 == 1 and is_prime[i] and is_prime[(i + 1) // 2]:
            counts.append(1)
        else:
            counts.append(0)
    
    for i in range(3, r + 1):
        counts[i] = counts[i] + counts[i - 1]


def main():
    Q = int(input())
    querys = []
    max_r = 0
    for i in range(Q):
        l, r = map(int, input().split())
        querys.append((l, r))
        if max_r < r:
            max_r = r

    sieve(max_r)
    calc_like_number_count(max_r)

    for l, r in querys:
        print(counts[r] - counts[l - 1])
    
main()
### BUGGY CODE ###

import heapq

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
To = [[[True] * Z for _ in range(Y)] for __ in range(X)]
Q = []
To[0][0][0] = False
heapq.heappush(Q, (-(A[0] + B[0] + C[0]), 0, 0, 0))
cnt = K
while cnt > 0:
    cnt -= 1
    ans, a, b, c = heapq.heappop(Q)
    print(-ans)
    if (a + 1 < X) and (To[a+1][b][c]):
        heapq.heappush(Q, (-(A[a + 1] + B[b] + C[c]), a + 1, b, c))
        To[a+1][b][c] = False
    if (b + 1 < Y) and (To[a][b+1][c]):
        heapq.heappush(Q, (-(A[a] + B[b + 1] + C[c]), a, b + 1, c))
        To[a][b+1][c] = False
    if (c + 1 < Z) and (To[a][b][c+1]):
        heapq.heappush(Q, (-(A[a] + B[b] + C[c + 1]), a, b, c + 1))
        To[a][b][c+1] = False


### FIXED CODE ###

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

D = []
for a in A:
    for b in B:
        D.append(a + b)
D.sort(reverse=True)
if len(D) > K:
    D = D[:K]
E = []
for d in D:
    for c in C:
        E.append(c + d)

E.sort(reverse=True)
for i, e in enumerate(E):
    if i >= K:
        break
    print(e)
### BUGGY CODE ###

from collections import deque
import sys
sys.setrecursionlimit(10**8)

def main():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    Ch -= 1
    Cw -= 1
    Dh -= 1
    Dw -= 1
    S = [list(input()) for _ in range(H)]
    visited = [[False] * W for _ in range(H)]
    cnt = [[float('inf')] * W for _ in range(H)]
    dh = [1,0,-1,0]
    dw = [0,1,0,-1]
    visited[Ch][Cw] = True
    cnt[Ch][Cw] = 0
    Q = deque([[Ch,Cw]])
    while Q:
        h, w = Q.popleft()
        if h == Dh and w == Dw:
            break
        for i in range(4):
            nh = h + dh[i]
            nw = w + dw[i]
            if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.':
                if cnt[nh][nw] > cnt[h][w]:
                    cnt[nh][nw] = cnt[h][w]
                    Q.append([nh,nw])
        for j in range(-2,3):
            for k in range(-2,3):
                nh = h + j
                nw = w + k
                if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.':
                    if cnt[nh][nw] > cnt[h][w]:
                        cnt[nh][nw] = cnt[h][w] + 1
                        visited[nh][nw] = True
                        Q.append([nh,nw])

    if cnt[Dh][Dw] == float('inf'):
        print(-1)
    else:
        print(cnt[Dh][Dw])




if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque
import sys
sys.setrecursionlimit(10**8)

def main():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    Ch -= 1
    Cw -= 1
    Dh -= 1
    Dw -= 1
    S = [list(input()) for _ in range(H)]
    visited = [[False] * W for _ in range(H)]
    cnt = [[float('inf')] * W for _ in range(H)]
    dh = [1,0,-1,0]
    dw = [0,1,0,-1]
    visited[Ch][Cw] = True
    cnt[Ch][Cw] = 0
    Q = deque([[Ch,Cw]])
    while Q:
        h, w = Q.popleft()
        c = cnt[h][w]
        if h == Dh and w == Dw:
            break
        for i in range(4):
            nh = h + dh[i]
            nw = w + dw[i]
            if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.':
                if cnt[nh][nw] > c:
                    cnt[nh][nw] = c
                    Q.appendleft([nh,nw])
        nc = c + 1
        for j in range(-2,3):
            for k in range(-2,3):
                nh = h + j
                nw = w + k
                if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.':
                    if cnt[nh][nw] > nc:
                        cnt[nh][nw] = nc
                        Q.append([nh,nw])

    if cnt[Dh][Dw] == float('inf'):
        print(-1)
    else:
        print(cnt[Dh][Dw])




if __name__ == "__main__":
    main()
### BUGGY CODE ###

from fractions import gcd

n=int(input())
a=list(map(int,input().split()))
mod = 10**9+7
c1=a[0]
res = 1
for i in range(1,n):
    c2=(c1*a[i])//gcd(c1,a[i])
    res = (res*(c2//c1))%mod+c2//a[i]
    res %= mod
    c1=c2
print(res)

### FIXED CODE ###

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

MOD = 10 ** 9 + 7

def gcd(x, y):
  while y: x, y = y, x % y
  return x

def lcm(x, y):
  return x * y // gcd(x, y)

tmp = A[0]
for i in range(1, N):
  tmp = lcm(A[i], tmp)
tmp %= MOD

answer = 0
for a in A:
  answer += tmp * pow(a, MOD - 2, MOD)
  
print(answer % MOD)
### BUGGY CODE ###

from math import inf
from random import randint
import time

def f(a,d,T):
    try:
        return T[d:].index(a)+d
    except ValueError:
        return len(T)

from random import randint
A=26

D=int(input())

C=[0]+list(map(int,input().split())) #減る満足度のベース
S=[0]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))
 
def g(d,q,S,C,T):
    p=T[d]

    a=f(p,d+1,T)
    b=f(q,d+1,T)
    
    Y=0
    h=L[d-1][p]
    for i in range(d,a):
        h+=1
        Y+=h-L[i][p]
        
    m=0
    Z=0
    for j in range(d,b):
        Z-=m-L[j][q]
        m+=1
        
    return (S[d][q]-S[d][p])-Z*C[q]+Y*C[p]

T=[0]
L=[[0]*(A+1) for _ in range(D+1)]
for d in range(1,D+1):
    M=-inf
    E=0

    for j in range(1,A+1):
        X=0
        for k in range(1,A+1):
            if j!=k:
                X-=C[k]*L[d][k]
                
        if M<=X+S[d][j]:
            M=X+S[d][j]
            E=j

    T.append(E)
    for j in range(1,A+1):
        if j!=E:
            L[d][j]=L[d-1][j]+1
        else:
            L[d][j]=0
            
START=time.time()
while time.time()-START<=1.98:
    e=randint(1,D)
    q=randint(1,A)

    V=g(e,q,S,C,T)
    if V>0:
        p=T[d]

        a=f(p,d+1,T)
        b=f(q,d+1,T)
        
        h=L[d-1][p]
        for i in range(d,a):
            h+=1
            L[i][p]=h

        m=0
        for j in range(d,b):
            L[j][q]=m
            m+=1
        T[d]=q
for i in range(1,D+1):
    print(T[i])


### FIXED CODE ###

from random import randint
A=26

D=int(input())

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

S=[0]*D
for i in range(D):
    S[i]=list(map(int,input().split()))

for j in range(D):
    print(randint(1,A))
### BUGGY CODE ###

N, M = [int(nm) for nm in input().split()]
A = [-1]
for m in range(M):
  A.append(int(input()))
A.append(N+1)

import math
total_case = 1
for m in range(M+1):
  a1 = A[m]
  a2 = A[m+1]
  safe_stairs = a2 - a1 - 1
  if safe_stairs == 0:
    print(0)
    break
  elif safe_stairs==1 or safe_stairs==2:
    total_case *= 1
    continue
  howmany_jump1 = safe_stairs - 1
  mx_jump2 = howmany_jump1 // 2
  #２のジャンプは０回～（mx_jump2）回
  case = 0
  for j2 in range(mx_jump2 + 1):
    jump2 = j2
    jump1 = howmany_jump1 - (j2 * 2)
    c = math.factorial(jump1 + jump2) // (math.factorial(jump1) * math.factorial(jump2))
    case += c
  total_case *= case
else:
  ans = total_case % (10**9 + 7)
  print(ans)

### FIXED CODE ###

N, M = [int(nm) for nm in input().split()]
if M != 0:
  a = int(input())

C = [1, 0] # [-2段目, -1段目]
C += [0]*(N+10) # C = [-2段目, -1段目, 0段目, 1段目, 2段目, ...]
for n in range(0, N+1):
  if M == 0:
    C[n+2] = (C[n] + C[n+1]) % 1000000007
  else: # M > 0:
    if n != a:
      C[n+2] = (C[n] + C[n+1]) % 1000000007
    else: # n == a:
      C[n+2] = 0
      M -= 1
      if M > 0:
        a = int(input())

ans = C[N+2]  % 1000000007
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
a.sort(reverse=True)
# 1-indexed
cumsum = [0] * (n + 1)
for i in range(n):
    cumsum[i+1] = cumsum[i] + a[i]
coef = [0] * (n + 1)
for i in range(n + 1):
    coef[i] = (2 + i) ** 2 - (1 + i) ** 2
coef[0] += 2

ans = 10**18
for trip in range(1, n+1):
    collected = 0
    to_take = (n + trip - 1) // trip
    score = k * trip + k * n
    for i in range(to_take):
        val = cumsum[min((i+1) * trip, n)] - cumsum[i * trip]
        score += val * coef[i]
    ans = min(ans, score)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
a.sort(reverse=True)
# 1-indexed
cumsum = [0] * (n + 1)
for i in range(n):
    cumsum[i+1] = cumsum[i] + a[i]
coef = [0] * (n + 1)
for i in range(n + 1):
    coef[i] = (2 + i) ** 2 - (1 + i) ** 2
coef[0] += 2

ans = 10**18
for trip in range(1, n+1):
    collected = 0
    to_take = (n + trip - 1) // trip
    score = k * trip + k * n
    for i in range(to_take):
        val = cumsum[min((i+1) * trip, n)] - cumsum[i * trip]
        score += val * coef[i]
    ans = min(ans, score)
print(ans)