CodeEff/ECCO huggingface dataset:
# Original solution
N, K, Q = [int(i) for i in input().split()]
A = []
for i in range(Q):
    A.append(int(eval(input()))-1)

for i in range(N):
    score = K - Q + A.count(i)
#    print(score)
    if score > 0:
        print('Yes')
    else:
        print('No')


# Optimized solution
N, K, Q = [int(i) for i in input().split()]

score = [K - Q] * N

for i in range(Q):
    score[int(eval(input()))-1] += 1

for i in range(N):
    if score[i] > 0:
        print('Yes')
    else:
        print('No')
# Original solution
n = int(eval(input()))
alist = list(reversed(sorted([int(eval(input())) for _ in range(n)])))
blist = list(reversed(sorted([int(eval(input())) for _ in range(n)])))
INF = pow(10, 9) + 7
a = alist.pop()
b = blist.pop()
aset, bset = 0, 0
ans = 1
while len(alist) > 0 or len(blist) > 0:
  if a < b:
    if bset > 0:
      ans *= bset
      bset -= 1
    else:
      aset += 1
    a = INF
    if len(alist) > 0:
      a = alist.pop()
  else:
    if aset > 0:
      ans *= aset
      aset -= 1
    else:
      bset += 1
    b = INF
    if len(blist) > 0:
      b = blist.pop()
print((ans % INF))


# Optimized solution
n = int(eval(input()))
alist = list(reversed(sorted([int(eval(input())) for _ in range(n)])))
blist = list(reversed(sorted([int(eval(input())) for _ in range(n)])))
INF = pow(10, 9) + 7
a = alist.pop()
b = blist.pop()
aset, bset = 0, 0
ans = 1
while len(alist) > 0 or len(blist) > 0:
  if a < b:
    if bset > 0:
      ans = (ans * bset) % INF
      bset -= 1
    else:
      aset += 1
    a = INF
    if len(alist) > 0:
      a = alist.pop()
  else:
    if aset > 0:
      ans = (ans * aset) % INF
      aset -= 1
    else:
      bset += 1
    b = INF
    if len(blist) > 0:
      b = blist.pop()
print((ans % INF))
# Original solution
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(eval(input()))
points = []
for i in range(N):
    a = int(eval(input()))
    points.append([a,True])
for i in range(N):
    b = int(eval(input()))
    points.append([b,False])
points.sort()

ans = 1
an = bn = 0
for x,c in points:
    if c:
        if bn > 0:
            ans = (ans*bn)%mod
            bn -= 1
        else:
            an += 1
    else:
        if an > 0:
            ans = (ans*an)%mod
            an -= 1
        else:
            bn += 1

print((ans%mod))


# Optimized solution
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
ab = []

for i in range(N):
    a = inp()
    ab.append([a,1])

for i in range(N):
    b = inp()
    ab.append([b,-1])

ab.sort()
cnt = 0
ans = 1
for x,k in ab:
    cnt += k
    if (cnt > 0) and (k > 0):
        ans *= cnt
    elif (cnt < 0) and (k < 0):
        ans *= -cnt
    ans %= mod
    
print((ans%mod))
# Original solution
mod = 10 ** 9 + 7

N = int(eval(input()))
A = [(int(eval(input())), -1) for _ in range(N)]
B = [(int(eval(input())), 1) for _ in range(N)]

C = sorted(A + B)

res = 1
cnt = 0
for _, delta in C:
    if cnt != 0 and cnt * delta < 0:
        res *= abs(cnt)
        res %= mod
    cnt += delta

print(res)

# Optimized solution
mod = 10 ** 9 + 7

N = int(eval(input()))
A = [(int(eval(input())), 1) for _ in range(N)]
B = [(int(eval(input())), -1) for _ in range(N)]

C = sorted(A + B)

res = 1
cnt = 0
for _, delta in C:
    if cnt * delta < 0:
        res *= abs(cnt)
        res %= mod
    cnt += delta

print(res)
# Original solution
mod = 10 ** 9 + 7

N, *E = list(map(int, open(0).read().split()))
E = sorted((e, 1 if i < N else -1) for i, e in enumerate(E))

res = 1
cnt = 0
for _, delta in E:
    if cnt * delta < 0:
        res *= abs(cnt)
        res %= mod
    cnt += delta

print(res)

# Optimized solution
mod = 10 ** 9 + 7

N, *E = list(map(int, open(0).read().split()))
E = sorted((e, 2 * (i < N) - 1) for i, e in enumerate(E))

res = 1
cnt = 0
for _, delta in E:
    if cnt * delta < 0:
        res *= abs(cnt)
        res %= mod
    cnt += delta

print(res)
# Original solution
N,*E=list(map(int,open(0).read().split()))
E=sorted((e,2*(i<N)-1)for i,e in enumerate(E))
a,c=1,0
for _,d in E:
	if c*d<0:a*=abs(c)
	c+=d
print((a%(10**9+7)))

# Optimized solution
N,*E=list(map(int,open(0).read().split()))
E=sorted((e,2*(i<N)-1)for i,e in enumerate(E))
a,c=1,0
for _,d in E:
	if c*d<0:a=abs(a*c)%(10**9+7)
	c+=d
print(a)
# Original solution
p=1
s=[0]*2
n=int(eval(input()))
q=sorted([[int(eval(input())),i//n]for i in range(2*n)])
for i in q:
    if s[1-i[1]]==0:
        s[i[1]]+=1
    else:
        p*=s[1-i[1]]
        s[1-i[1]]-=1
print((p%(10**9+7)))

# Optimized solution
p=1
m=10**9+7
s=[0]*2
n=int(eval(input()))
q=sorted([[int(eval(input())),i//n]for i in range(2*n)])
for i in q:
    if s[1-i[1]]==0:
        s[i[1]]+=1
    else:
        p=(p*s[1-i[1]])%m
        s[1-i[1]]-=1
print(p)
# Original solution
import bisect
N = int(eval(input()))
A = sorted(int(eval(input())) for _ in range(N))
B = sorted(int(eval(input())) for _ in range(N))
mod = 10**9 + 7
ans = 1
b = bisect.bisect
for i in range(N):
    if A[i] < B[i]:
        ans *= 1 + i - b(B[:i], A[i])
    else:
        ans *= 1 + i - b(A[:i], B[i])
    ans %= mod
print(ans)


# Optimized solution
N = int(eval(input()))
E = []
for _ in range(N):
    E += [(int(eval(input())), 1)]
for _ in range(N):
    E += [(int(eval(input())), -1)]
E.sort()
mod = 10**9 + 7
ans = 1
ab = 0
for e in E:
    if e[1] * ab < 0:
        ans *= abs(ab)
        ans %= mod
    ab += e[1]
print(ans)
# Original solution
import sys
from operator import itemgetter

read = sys.stdin.read

N, *ab = list(map(int, read().split()))
mod = 10 ** 9 + 7
ab = list(zip(ab[:N], [0] * N)) + list(zip(ab[N:], [1] * N))
ab.sort(key=itemgetter(0))

remain_pc = 0
remain_power = 0
answer = 1

for x, p in ab:
    if p == 0:
        if remain_power == 0:
            remain_pc += 1
            continue
        answer *= remain_power
        remain_power -= 1
    else:
        if remain_pc == 0:
            remain_power += 1
            continue
        answer *= remain_pc
        remain_pc -= 1
    answer %= mod

print(answer)


# Optimized solution
import sys
from operator import itemgetter

read = sys.stdin.read

N, *ab = list(map(int, read().split()))
mod = 10 ** 9 + 7
ab = list(zip(ab, [0] * N + [1] * N))
ab.sort(key=itemgetter(0))

remain_pc = 0
remain_power = 0
answer = 1

for x, p in ab:
    if p == 0:
        if remain_power == 0:
            remain_pc += 1
            continue
        answer *= remain_power
        remain_power -= 1
    else:
        if remain_pc == 0:
            remain_power += 1
            continue
        answer *= remain_pc
        remain_pc -= 1
    answer %= mod

print(answer)
# Original solution
n=int(eval(input()))
mod=10**9+7
X=[]
for i in range(n):
  X.append([int(eval(input())),0])
for i in range(n):
  X.append([int(eval(input())),1])
X.sort(key=lambda x:x[0])
ct=0
Y=[]
for a,b in X:
  if b==0:
    ct+=1
  else:
    ct-=1
  Y.append(ct)
ans=1
m,mm=0,1
key=0
for i in range(2*n):
  if Y[i]==0:
    ans*=mm
    m,mm=0,1
  elif m==0:
    m=1
    key=X[i][1]
  else:
    if X[i][1]==key:
      m+=1
      mm*=m
    else:
      m-=1
print((ans%mod))


# Optimized solution
n=int(eval(input()))
ans=1
mod=10**9+7
A=[0,0]
AB=[]
for i in range(n):
  a=int(eval(input()))
  AB.append((a,0))
for i in range(n):
  b=int(eval(input()))
  AB.append((b,1))
AB.sort(key=lambda x:x[0])
for i in range(2*n):
  a,b=AB[i]
  if b==0:
    if A[1]>0:
      ans=(ans*A[1])%mod
      A[1]-=1
    else:
      A[0]+=1
  else:
    if A[0]>0:
      ans=(ans*A[0])%mod
      A[0]-=1
    else:
      A[1]+=1
print(ans)
# Original solution
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
B = [int(eval(input())) for _ in range(N)]
A.sort()
B.sort()
ans = [0] * N
mod = 10**9 + 7

for i in range(N):
    for j in range(N):
        ans[j-i] += (abs(A[i]-B[j])) % mod

print((ans.count(min(ans))))

# Optimized solution
N = int(eval(input()))
Q = sorted([[int(eval(input())), i//N] for i in range(2*N)])

mod = 10**9 + 7
ans = 1
S = [0, 0]

for i in Q:
    if S[1-i[1]] == 0:
        S[i[1]] += 1
    else:
        ans = (ans*S[1-i[1]]) % mod
        S[1-i[1]] -= 1

print(ans)
# Original solution
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=list(map(int, input().split()))
    if n==1 and m==1:
        ans=1
    elif m==1:
        ans=max(0,n-2)
    elif n==1:
        ans=max(0,m-2)
    else:
        ans=(n-2)*(m-2)
    print(ans)
resolve()

# Optimized solution
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=list(map(int, input().split()))
    if n==1 and m==1:
        ans=1
    # n,m=1,1を除外してるからどっちか１だったら他方の-2でok
    elif m==1:
        ans=n-2
    elif n==1:
        ans=m-2
    else:
        ans=(n-2)*(m-2)
    print(ans)
resolve()
# Original solution

def calc0(N, M):
    cell = [[0 for i in range(M)] for j in range(N)]
    for i in range(M):
        for j in range(N):
            for y in range(-1, 2):
                for x in range(-1, 2):
                    xx = i + x
                    yy = j + y
                    if 0 <= xx < M and 0 <= yy < N:
                        cell[yy][xx] ^= 1
    r = 0
    for i in range(M):
        for j in range(N):
            if cell[j][i]:
                r += 1
    return r
    
def calc(N, M):
    if N == 1 and M == 1:
        return 1
    if N >= 2 and M >= 2:
        return (N - 2) * (M - 2)
    if N == 1:
        return M - 2
    return N - 2

N, M = [int(_) for _ in input().split()]

print((calc(N, M)))



# Optimized solution
def calc(N, M):
    if N == 1 and M == 1:
        return 1
    if N == 1:
        return M - 2
    if M == 1:
        return N - 2
    # N >= 2 and M >= 2:
    return (N - 2) * (M - 2)

N, M = [int(_) for _ in input().split()]

print((calc(N, M)))
# Original solution
n,m=list(map(int,input().split()))

# 上端
edge_l=1
if m > 1:
    edge_l+=1
if n > 1:
    edge_l+=1
if m > 1 and n > 1:
    edge_l+=1

edge_l = 1 if edge_l%2==1 else 0

edge_c=3
if n > 1:
    edge_c+=3
edge_c = 1 if edge_c%2==1 else 0

edge_row=edge_l
if m>1:
    edge_row+=edge_l
if m>2:
    edge_row+=(m-2)*edge_c

# 中央部
inner_l = 3
if m > 1:
    inner_l+=3
inner_l = 1 if inner_l%2==1 else 0

inner_c=1 # 絶対に裏

inner_row=inner_l
if m>1:
    inner_row+=inner_l
if m>2:
    inner_row+=(m-2)*inner_c

# 合計
total=edge_row
if n>1:
    total+=edge_row
if n>2:
    total+=(n-2)*inner_row
print(total)


# Optimized solution
n,m = list(map(int,input().split()))
print(((n-2)*(m-2) if n>1 and m>1 else abs(abs(n-m)-1)))
# Original solution
def dxdy(n, m, x, y):
    dx = [0,0,1,1,1,-1,-1,-1]
    dy = [1,-1,0,1,-1,0,1,-1]

    cnt = 1
    for i in range(8):
        if 0<=x+dx[i] and x+dx[i]<n and 0<=y+dy[i] and y+dy[i]<m:
            cnt += 1

    return cnt

def solve():
    n, m = list(map(int, input().split()))

    ans = 0

    for i in range(n):
        for j in range(m):
            if dxdy(n, m, i, j)%2 == 1:
                ans += 1

    return ans

print((solve()))


# Optimized solution
def solve():
    n, m = list(map(int, input().split()))

    ans = abs(0*4 + 0*(n-2)*2 + 0*(m-2)*2 + 1*(n-2)*(m-2))

    return ans

print((solve()))
# Original solution
def main():
    N, M = list(map(int, input().split()))

    def judge(r, c):
        if r >= N or c >= M:
            return 0

        if ~memo[r][c]:
            return 0

        ux = (r == 0)  # 上がない
        bx = (r == N - 1)  # 下がない
        lx = (c == 0)  # 左がない
        rx = (c == M - 1)  # 右がない

        ret = 9  # マスと周囲がすべて存在するときの反転回数
        ret -= (ux + bx + lx + rx) * 3 - (ux & lx) - (ux & rx) - (bx & lx) - (bx & rx)
        return ret & 1  # 奇数回反転->裏向き

    memo = [[-1] * 2 for _ in range(2)]
    # gridの左上の2x2マスの反転判定

    for r in range(2):
        for c in range(2):
            memo[r][c] = judge(r=r, c=c)

    ans = memo[0][0] + memo[1][0] * (N - 2) + memo[0][1] * (M - 2) + memo[1][1] * (N - 2) * (M - 2)

    # print(*memo, sep='\n')
    print(ans)


if __name__ == '__main__':
    main()

# (0,0)
# (1...N-2,0)
# (N-1,0)

# (0,1...M-2)
# (1...N-2,1...M-2)
# (N-1,1...M-2)

# (0,M-1)
# (1...N-2,M-1)
# (N-1,M-1)


# Optimized solution
def main():
    N, M = list(map(int, input().split()))

    if N > M:
        N, M = M, N

    if (N, M) == (1, 1):
        print((1))
        return

    if N == 1:
        print((M - 2))
        return

    print(((N - 2) * (M - 2)))


if __name__ == '__main__':
    main()
# Original solution
dx = [-1, -1, -1, 0, 1, 1, 1, 0]
dy = [1, 0, -1, -1, -1, 0, 1, 1]

# 0 裏 1 表
n, m = list(map(int, input().split()))
count = 0
if n == 1 or m == 1:
    for i in range(n):
        for j in range(m):
            xy_count = 0
            for x, y in zip(dx, dy):
                if i + y == -1 or i + y == n or j + x == -1 or j + x == m:
                    continue
                # lis[i + y][j + x] = not lis[i + y][j + x]
                xy_count += 1
            if xy_count % 2 == 0:
                count += 1
    print(count)
else:
    print((n * m - (2 * n + 2 * m - 4)))

# Optimized solution
n, m = list(map(int, input().split()))
print((abs(n * m - (2 * n + 2 * m - 4))))
# Original solution
N, M = list(map(int, input().split()))
result = 0
pos = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1)]
for i in range(N):
    for j in range(M):
        num = 0
        for p in pos:
            i_dest = i + p[0]
            j_dest = j + p[1]
            if 0 <= i_dest < N and 0 <= j_dest < M:
                num += 1
        if num % 2 != 0:
            result += 1
print(result)


# Optimized solution
N, M = list(map(int, input().split()))
result = 0
if N == 1 and M == 1:
    result = 1
elif N == 1:
    result = M - 2
elif M == 1:
    result = N - 2
else:
    result = (N - 2) * (M - 2)
print(result)
# Original solution
N, M = list(map(int, input().split()))

if N == 2 or M == 2:
    print((0))

else:
    print((abs((N - 2) * (M - 2))))

# Optimized solution
N, M = list(map(int, input().split()))
print((abs((N - 2) * (M - 2))))
# Original solution
a,b = list(map(int,input().split(" ")))
if a == 1 and b == 1:
  print((1))
elif a == 1 or b == 1:
  print((a * b - 2))
else:
  print(((a-2) * (b-2)))

# Optimized solution
h,w = list(map(int,input().split(" ")))
if h == 1 and w == 1:
    print((1))
elif h == 1:
    print((w - 2))
elif w == 1:
    print((h - 2))
else:
    print(((h - 2) * (w - 2)))
# Original solution
N,M=list(map(int,input().split()))

if N==1 and M==1:
    ans=1
elif N==1 and M==2:
    ans=0
elif N==1 and M>=3:
    ans=M-2
elif N==2 and M==1:
    ans=0
elif N==2 and M==2:
    ans=0
elif M==1 and N>=3:
    ans=N-2
else:
    ans=(N-2)*(M-2)

print(ans)

# Optimized solution
N,M=list(map(int,input().split()))

if N==1 and M==1:
    ans=1
elif N==1 and M>=2:
    ans=M-2
elif M==1 and N>=2:
    ans=N-2
else:
    ans=(N-2)*(M-2)

print(ans)
# Original solution
n = []
while True:
    try:
        tmp = int(eval(input()))
        if tmp == 0:
            break
        else:
            n.append(tmp)
    except EOFError:
        break

for i in range(len(n)):
    f = 1
    for j in range(1,n[i]+1):
        f *= j
    k = 0
    while True:
        if f % (10 ** k) != 0:
            print((k-1))
            break
        else:
            k += 1

# Optimized solution
import math
# ????????§??????????????????????????????
def fact(n):
    sum = 0
    for i in range(1,n+1):
        sum += math.log(i)
    return math.exp(sum)
def fact2(n):
    return math.sqrt(2*math.pi*n)*(n/math.exp(1))**n

n = []
while True:
    try:
        tmp = int(eval(input()))
        if tmp == 0:
            break
        else:
            n.append(tmp)
    except EOFError:
        break

for i in range(len(n)):
    f = math.factorial(n[i])
    k = 0
    while True:
        if f % (10 ** k) != 0:
            print((k-1))
            break
        else:
            k += 1
# Original solution
import math
# ????????§??????????????????????????????
def fact(n):
    sum = 0
    for i in range(1,n+1):
        sum += math.log(i)
    return math.exp(sum)
# ????????????????????§??????
def fact2(n):
    return math.sqrt(2*math.pi*n)*(n/math.exp(1))**n

def mfactorial(n, _factcache={}):
  if n not in _factcache:
    _factcache[n] = math.factorial(n)
  return _factcache[n]


n = []
while True:
    try:
        tmp = int(eval(input()))
        if tmp == 0:
            break
        else:
            n.append(tmp)
    except EOFError:
        break

for i in range(len(n)):
    f = mfactorial(n[i])
    k = 0
    while True:
        if f % (10 ** k) != 0:
            print((k-1))
            break
        else:
            k += 1

# Optimized solution
n = []
while True:
    try:
        tmp = int(eval(input()))
        if tmp == 0:
            break
        else:
            n.append(tmp)
    except EOFError:
        break

for i in range(len(n)):
    c = 0
    d = 5
    for j in range(1,n[i]+1):
        while d <= n[i]:
            c += (n[i]//d)
            d *= 5
    print(c)
# Original solution

N,C = list(map(int,input().split()))
h = list(map(int,input().split()))
#print(h)

dp = [0]*N
dp[0] = 0
for n in range(1,N):
	best = 99999999999999
	for k in range(1,N):
		if n-k<0: continue
		step = C+(h[n]-h[n-k])**2+dp[n-k]
		best = min(best,step)
	dp[n] = best

ans = dp[N-1]
print(ans)


# Optimized solution

class ConvexHullTrick:
	length = 0

	def __init__(self,size):
		self.A = [0]*size
		self.B = [0]*size

	def check(self,a,b):
		lhs = (self.B[self.length-2]-self.B[self.length-1])*(a-self.A[self.length-1])
		rhs = (self.B[self.length-1]-b)*(self.A[self.length-1]-self.A[self.length-2])
		return lhs>=rhs

	# 直線の傾きaは単調現象であること
	# Add a line y=a*x+b
	def add(self,a,b):
		while 2<=self.length and self.check(a,b):
			self.length -= 1
		self.A[self.length] = a
		self.B[self.length] = b
		self.length += 1
		return
	# min_i {a[i]*x+b[i]}
	def query(self,x):
		l,r = -1, self.length-1
		while l+1<r:
			m = (l+r)//2
			if self.eval(m+1,x)<=self.eval(m,x):
				l = m
			else:
				r = m
		return self.eval(r,x)

	def eval(self,k,x):
		return self.A[k]*x + self.B[k]

N,C = list(map(int,input().split()))
h = list(map(int,input().split()))
#print(h)

cht = ConvexHullTrick(N)

dp = [0]*N
dp[0] = 0
cht.add(-2*h[0],h[0]**2+dp[0])
for i in range(1,N):
	#best = 99999999999999
	# for j in range(i):
	# 	#cost = dp[j]+(h[i]-h[j])**2+C
	# 	cost = (-2*h[j])*h[i]+(h[j]**2+dp[j])
	# 	best = min(best,cost)
	best = cht.query(h[i])
	dp[i] = best+h[i]**2+C

	cht.add(-2*h[i],h[i]**2+dp[i])

ans = dp[N-1]
print(ans)
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque

N,C,*H = list(map(int,read().split()))

class CHT:
    """
    f_i = a_ix + b_i とする。f_i の追加および、min_i f(x) の取得ができるデータ構造。
    ただし、傾き a_i は昇順に追加されなければならない。
    また、クエリ x も昇順に実行されなければならない。
    """
    def __init__(self):
        self.funcs = deque()

    def add(self,a,b):
        funcs = self.funcs
        while len(funcs) >= 2:
            a1,b1 = funcs[-2]
            a2,b2 = funcs[-1]
            if (a2-a1)*(b-b2) < (b2-b1)*(a-a2):
                break
            funcs.pop()
        funcs.append((a,b))

    def query(self,x):
        funcs = self.funcs
        a,b = funcs[0]
        y = a*x+b
        while len(funcs) >= 2:
            a2,b2 = self.funcs[1]
            y2 = a2*x+b2
            if y < y2:
                break
            y = y2
            self.funcs.popleft()
        return y

dp = [0] * N
cht = CHT()

h = H[0]
cht.add(-2*h, h*h)
for i,h in enumerate(H[1:],1):
    x = cht.query(h) + h*h + C
    dp[i] = x
    cht.add(-2*h, h*h + x)

answer = dp[-1]
print(answer)

# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque

N,C,*H = list(map(int,read().split()))

class CHT:
    """
    f_i = a_ix + b_i とする。f_i の追加および、min_i f(x) の取得ができるデータ構造。
    ただし、傾き a_i は昇順に追加されなければならない。
    また、クエリ x も昇順に実行されなければならない。
    """
    def __init__(self):
        self.funcs = deque()

    def add(self,a,b):
        funcs = self.funcs
        while len(funcs) >= 2:
            a1,b1 = funcs[-2]
            a2,b2 = funcs[-1]
            if (a2-a1)*(b-b2) < (b2-b1)*(a-a2):
                break
            funcs.pop()
        funcs.append((a,b))

    def query(self,x):
        funcs = self.funcs
        a,b = funcs[0]
        y = a*x+b
        while len(funcs) >= 2:
            a2,b2 = self.funcs[1]
            y2 = a2*x+b2
            if y < y2:
                break
            y = y2
            self.funcs.popleft()
        return y

dp = [0] * N
cht = CHT()

h = H[0]
add = cht.add
query = cht.query

add(-2*h, h*h)
for i,h in enumerate(H[1:],1):
    x = query(h) + h*h + C
    dp[i] = x
    add(-2*h, h*h + x)

answer = dp[-1]
print(answer)
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque

N,C,*H = list(map(int,read().split()))

class CHT:
    """
    f_i = a_ix + b_i とする。f_i の追加および、min_i f(x) の取得ができるデータ構造。
    ただし、傾き a_i は昇順に追加されなければならない。
    また、クエリ x も昇順に実行されなければならない。
    """
    def __init__(self):
        self.funcs = deque()

    def add(self,a,b):
        funcs = self.funcs
        while len(funcs) >= 2:
            a1,b1 = funcs[-2]
            a2,b2 = funcs[-1]
            if (a2-a1)*(b-b2) < (b2-b1)*(a-a2):
                break
            funcs.pop()
        funcs.append((a,b))

    def query(self,x):
        funcs = self.funcs
        a,b = funcs[0]
        y = a*x+b
        while len(funcs) >= 2:
            a2,b2 = funcs[1]
            y2 = a2*x+b2
            if y < y2:
                break
            y = y2
            funcs.popleft()
        return y

dp = [0] * N
cht = CHT()
add = cht.add; query = cht.query

h = H[0]
add(-2*h, h*h)
for i,h in enumerate(H[1:],1):
    x = query(h) + h*h + C
    dp[i] = x
    add(-2*h, h*h + x)

answer = dp[-1]
print(answer)

# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque

N,C,*H = list(map(int,read().split()))

class ConvexHullTrick:
    """
    f_i = a_ix + b_i とする。f_i の追加および、min_i f(x) の取得ができるデータ構造。
    ただし、傾き a_i は昇順に追加されなければならない。
    また、クエリ x も昇順に実行されなければならない。
    """
    def __init__(self):
        self.funcs = deque()

    def add(self,a,b):
        funcs = self.funcs
        while len(funcs) >= 2:
            a1,b1 = funcs[-2]
            a2,b2 = funcs[-1]
            if (a2-a1)*(b-b2) < (b2-b1)*(a-a2):
                break
            funcs.pop()
        funcs.append((a,b))

    def query(self,x):
        funcs = self.funcs
        a,b = funcs[0]
        y = a*x+b
        while len(funcs) >= 2:
            a2,b2 = funcs[1]
            y2 = a2*x+b2
            if y < y2:
                break
            y = y2
            funcs.popleft()
        return y

dp = [0] * N
cht = ConvexHullTrick()
add = cht.add; query = cht.query

h = H[0]
add(-2*h, h*h)
for i,h in enumerate(H[1:],1):
    x = query(h) + h*h + C
    dp[i] = x
    add(-2*h, h*h + x)

answer = dp[-1]
print(answer)