class Lichaotree:

    #区間は1-indexed

    #min

    def __init__(self, X):

        self.N = len(X)

        self.N0 = 2**(self.N-1).bit_length()

        self.comp = {v : k for k, v in enumerate(X)}

        self.inf = 10**19

        self.X = X + [self.inf]*(self.N0 - self.N)

        self.data = [None]*(2*self.N0)

        self.size = [0]*self.N0 + [1]*self.N0

        for i in range(self.N0-1, 0, -1):

            self.size[i] = 2*self.size[2*i]

        

    def f(self, line, x):

        return line[0]*x + line[1]



    def _update(self, k, line):

        

        if self.data[k] is None:

            self.data[k] = line

            return

        

        l = k - (1 << (k.bit_length() - 1))

        r = l + self.size[k]



        

        while True:

            if self.data[k] is None:

                self.data[k] = line

                return

            

            m = (l+r)//2

            lx = self.X[l]

            mx = self.X[m]

            rx = self.X[r-1]

            gl = (self.f(self.data[k], lx) > self.f(line, lx))

            gm = (self.f(self.data[k], mx) > self.f(line, mx))

            gr = (self.f(self.data[k], rx) > self.f(line, rx))

            if gl and gr:

                self.data[k] = line

                return

            

            if not gl and not gr:

                return

            

            if gm:

                self.data[k], line = line, self.data[k]

                gl = not gl

                

            if gl:

                r = m

                k = 2*k

            else:

                l = m

                k = 2*k+1

    

    def query(self, x):

        k = self.comp[x] + self.N0

        s = self.inf

        while k > 0:

            if self.data[k]:

                s = min(s, self.f(self.data[k], x))

            k = k >> 1

        return s

            

    def addline(self, line):

        self._update(1, line)



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

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



T = Lichaotree(H)

dp = [10**19]*N

dp[0] = 0

T.addline((-2*H[0], H[0]**2))

for i in range(1,N):

    mi = T.query(H[i])

    dp[i] = mi + C + H[i]**2

    T.addline((-2*H[i], H[i]**2+dp[i]))

print((dp[-1]))

class Lichaotree:

    #区間は1-indexed

    #min

    def __init__(self, X):

        self.N = len(X)

        self.N0 = 2**(self.N-1).bit_length()

        self.comp = {v : k for k, v in enumerate(X)}

        self.inf = 10**12

        self.X = X + [self.inf]*(self.N0 - self.N)

        self.data = [None]*(2*self.N0)

        self.size = [0]*self.N0 + [1]*self.N0

        for i in range(self.N0-1, 0, -1):

            self.size[i] = 2*self.size[2*i]

        self.start = [0]*(2*self.N0)

        for i in range(1, 2*self.N0):

            if i == i&(-i):

                continue

            self.start[i] = self.start[i-1] + self.size[i]

        

    def f(self, line, x):

        return line[0]*x + line[1]



    def _update(self, k, line):

        

        if self.data[k] is None:

            self.data[k] = line

            return

        

        l = self.start[k]

        r = l + self.size[k]        

        

        while True:

            if self.data[k] is None:

                self.data[k] = line

                return

            

            m = (l+r)//2

            lx = self.X[l]

            mx = self.X[m]

            rx = self.X[r-1]

            gl = (self.f(self.data[k], lx) > self.f(line, lx))

            gm = (self.f(self.data[k], mx) > self.f(line, mx))

            gr = (self.f(self.data[k], rx) > self.f(line, rx))

            if gl and gr:

                self.data[k] = line

                return

            

            if not gl and not gr:

                return

            

            if gm:

                self.data[k], line = line, self.data[k]

                gl = not gl

                

            if gl:

                r = m

                k = 2*k

            else:

                l = m

                k = 2*k+1

    

    def query(self, x):

        k = self.comp[x] + self.N0

        s = self.inf

        while k > 0:

            if self.data[k]:

                s = min(s, self.f(self.data[k], x))

            k = k >> 1

        return s

            

    def addline(self, line):

        self._update(1, line)

    

    def addlineseg(self, l, r, line):

        #区間[l, r)にlineを追加,l, rはXの元

        

        L = l+self.N0

        R = r+self.N0

        while L < R:

            if R & 1:

                R -= 1

                self._update(R, line)

            if L & 1:

                self._update(L, line)

                L += 1

            L >>= 1

            R >>= 1



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

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



T = Lichaotree(H)

dp = [10**19]*N

dp[0] = 0

T.addline((-2*H[0], H[0]**2))

for i in range(1,N):

    mi = T.query(H[i])

    dp[i] = mi + C + H[i]**2

    T.addline((-2*H[i], H[i]**2+dp[i]))

print((dp[-1]))

class Lichaotree:
    # 区間は1-indexed
    # min
    def __init__(self, X):
        self.N = len(X)
        self.N0 = 2 ** (self.N - 1).bit_length()
        self.comp = {v: k for k, v in enumerate(X)}
        self.inf = 10**19
        self.X = X + [self.inf] * (self.N0 - self.N)
        self.data = [None] * (2 * self.N0)
        self.size = [0] * self.N0 + [1] * self.N0
        for i in range(self.N0 - 1, 0, -1):
            self.size[i] = 2 * self.size[2 * i]

    def f(self, line, x):
        return line[0] * x + line[1]

    def _update(self, k, line):
        if self.data[k] is None:
            self.data[k] = line
            return
        l = k - (1 << (k.bit_length() - 1))
        r = l + self.size[k]
        while True:
            if self.data[k] is None:
                self.data[k] = line
                return
            m = (l + r) // 2
            lx = self.X[l]
            mx = self.X[m]
            rx = self.X[r - 1]
            gl = self.f(self.data[k], lx) > self.f(line, lx)
            gm = self.f(self.data[k], mx) > self.f(line, mx)
            gr = self.f(self.data[k], rx) > self.f(line, rx)
            if gl and gr:
                self.data[k] = line
                return
            if not gl and not gr:
                return
            if gm:
                self.data[k], line = line, self.data[k]
                gl = not gl
            if gl:
                r = m
                k = 2 * k
            else:
                l = m
                k = 2 * k + 1

    def query(self, x):
        k = self.comp[x] + self.N0
        s = self.inf
        while k > 0:
            if self.data[k]:
                s = min(s, self.f(self.data[k], x))
            k = k >> 1
        return s

    def addline(self, line):
        self._update(1, line)


N, C = list(map(int, input().split()))
H = list(map(int, input().split()))
T = Lichaotree(H)
dp = [10**19] * N
dp[0] = 0
T.addline((-2 * H[0], H[0] ** 2))
for i in range(1, N):
    mi = T.query(H[i])
    dp[i] = mi + C + H[i] ** 2
    T.addline((-2 * H[i], H[i] ** 2 + dp[i]))
print((dp[-1]))

class Lichaotree:
    # 区間は1-indexed
    # min
    def __init__(self, X):
        self.N = len(X)
        self.N0 = 2 ** (self.N - 1).bit_length()
        self.comp = {v: k for k, v in enumerate(X)}
        self.inf = 10**12
        self.X = X + [self.inf] * (self.N0 - self.N)
        self.data = [None] * (2 * self.N0)
        self.size = [0] * self.N0 + [1] * self.N0
        for i in range(self.N0 - 1, 0, -1):
            self.size[i] = 2 * self.size[2 * i]
        self.start = [0] * (2 * self.N0)
        for i in range(1, 2 * self.N0):
            if i == i & (-i):
                continue
            self.start[i] = self.start[i - 1] + self.size[i]

    def f(self, line, x):
        return line[0] * x + line[1]

    def _update(self, k, line):
        if self.data[k] is None:
            self.data[k] = line
            return
        l = self.start[k]
        r = l + self.size[k]
        while True:
            if self.data[k] is None:
                self.data[k] = line
                return
            m = (l + r) // 2
            lx = self.X[l]
            mx = self.X[m]
            rx = self.X[r - 1]
            gl = self.f(self.data[k], lx) > self.f(line, lx)
            gm = self.f(self.data[k], mx) > self.f(line, mx)
            gr = self.f(self.data[k], rx) > self.f(line, rx)
            if gl and gr:
                self.data[k] = line
                return
            if not gl and not gr:
                return
            if gm:
                self.data[k], line = line, self.data[k]
                gl = not gl
            if gl:
                r = m
                k = 2 * k
            else:
                l = m
                k = 2 * k + 1

    def query(self, x):
        k = self.comp[x] + self.N0
        s = self.inf
        while k > 0:
            if self.data[k]:
                s = min(s, self.f(self.data[k], x))
            k = k >> 1
        return s

    def addline(self, line):
        self._update(1, line)

    def addlineseg(self, l, r, line):
        # 区間[l, r)にlineを追加,l, rはXの元
        L = l + self.N0
        R = r + self.N0
        while L < R:
            if R & 1:
                R -= 1
                self._update(R, line)
            if L & 1:
                self._update(L, line)
                L += 1
            L >>= 1
            R >>= 1


N, C = list(map(int, input().split()))
H = list(map(int, input().split()))
T = Lichaotree(H)
dp = [10**19] * N
dp[0] = 0
T.addline((-2 * H[0], H[0] ** 2))
for i in range(1, N):
    mi = T.query(H[i])
    dp[i] = mi + C + H[i] ** 2
    T.addline((-2 * H[i], H[i] ** 2 + dp[i]))
print((dp[-1]))

-        self.inf = 10**19 +        self.inf = 10**12 +        self.start = [0] * (2 * self.N0) +        for i in range(1, 2 * self.N0): +            if i == i & (-i): +                continue +            self.start[i] = self.start[i - 1] + self.size[i] -        l = k - (1 << (k.bit_length() - 1)) +        l = self.start[k] +    def addlineseg(self, l, r, line): +        # 区間[l, r)にlineを追加,l, rはXの元 +        L = l + self.N0 +        R = r + self.N0 +        while L < R: +            if R & 1: +                R -= 1 +                self._update(R, line) +            if L & 1: +                self._update(L, line) +                L += 1 +            L >>= 1 +            R >>= 1 +