#include <iostream>
#include <vector>
#include <set>
//!================================================================================================!//
//!  888888ba                                        oo              a88888b. dP     dP  d888888P  !//
//!  88    '8b                                                      d8'   '88 88     88     88     !//
//!  88     88 dP    dP 88d888b. .d8888b. 88d8b.d8b. dP .d8888b.    88        88aaaaa88a    88     !//
//!  88     88 88    88 88'  '88 88'  '88 88''88''88 88 88'  '""    88        88     88     88     !//
//!  88    .8P 88.  .88 88    88 88.  .88 88  88  88 88 88.  ...    Y8.   .88 88     88     88     !//
//!  8888888P  '8888P88 dP    dP '88888P8 dP  dP  dP dP '88888P'     Y88888P' dP     dP     dP     !//
//!                 .88                                                                            !//
//!             d8888P                                                                             !//
//!================================================================================================!//
template <typename T, typename V = T>
class DynamicCHT
{
    struct Line
    {
        T a, b;
        bool query;
        mutable const Line* next = nullptr;
        bool operator<(const Line& l) const
        {
            if (not l.query) { return a > l.a; }
            if (not next) { return false; }
            return next->b - b < V(a - next->a) * l.a;
        }
        void printDebug() const { std::cerr << a << "x" + b; }
    };
    bool needless(const typename std::multiset<Line>::iterator y) const
    {
        const auto z = std::next(y);
        if (y == lines.begin()) { return z != lines.end() and y->a == z->a and y->b >= z->b; }
        const auto x = std::prev(y);
        return z == lines.end() ? y->a == x->a and y->b >= x->b : V(x->b - y->b) * (z->a - y->a) >= V(y->b - z->b) * (y->a - x->a);
    }
    std::multiset<Line> lines;

public:
    void add(const T a, const T b)
    {
        auto y = lines.insert({a, b, false});
        if (needless(y)) { return (void)lines.erase(y); }
        auto z = std::next(y);
        while (z != lines.end() and needless(z)) { z = lines.erase(z); }
        if (z != lines.end()) { y->next = &*z; }
        while (y != lines.begin() and needless(z = std::prev(y))) { lines.erase(z); }
        if (y != lines.begin()) { z->next = &*y; }
    }
    V query(const T x) const
    {
        const auto l = *lines.lower_bound(Line{x, 0, true});
        return (V)l.a * x + l.b;
    }
    void debugPrint() const
    {
        std::cerr << "[";
        std::size_t i = 0;
        for (const auto& l : lines) { l.debugPrint() << (i + 1 == lines.size() ? "" : ","), i++; }
        std::cerr << "]\n";
    }
};
using ll = long long;
using ull = unsigned long long;
int main()
{
    std::size_t N;
    ll C;
    std::cin >> N >> C;
    std::vector<ll> h(N), dp(N);
    for (std::size_t i = 0; i < N; i++) { std::cin >> h[i]; }
    DynamicCHT<ll> cht;
    cht.add(-2 * h[0], dp[0] + h[0] * h[0]);
    for (std::size_t i = 0; i < N; i++) {
        dp[i] = cht.query(h[i]) + h[i] * h[i] + C;
        cht.add(-2 * h[i], dp[i] + h[i] * h[i]);
    }
    std::cout << dp[N - 1] << std::endl;
    return 0;
}


Measured memory_bytes: 18944