#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5;
int a[N+1];
int n,c;
__int128_t dp[N+1];
struct line{
    int a,b;
    line() {a=0,b=0;}
    int val(int x){
        return a*x+b;
    }
};
vector<line>vec;
bool check(line x1,line x2,line x3){
    return 1.0*(x3.b-x2.b)/(x2.a-x3.a)>1.0*(x2.b-x1.b)/(x1.a-x2.a);
}
void add(line x){
    while(vec.size()>=2&&!check(vec[vec.size()-1],vec[vec.size()-2],x)){
        vec.pop_back();
    }
    vec.push_back(x);
}
int get(int x){
    int l=0,r=vec.size()-1;
    int ans=0;
    while(l<=r){
        int m1=l+(r-l)/3;
        int m2=r-(r-l)/3;
        if(vec[m1].val(x)<vec[m2].val(x)){
            ans=vec[m1].val(x);
            r=m2-1;
        }
        else{
            ans=vec[m2].val(x);
            l=m1+1;
        }
    }
    return ans;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n>>c;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    line x;
    x.a=-2*a[1];
    x.b=a[1]*a[1];
    add(x);
    for(int i=2;i<=n;i++){
        dp[i]=get(a[i])+a[i]*a[i]+c;
        x.a=-2*a[i];
        x.b=a[i]*a[i]+dp[i];
        add(x);
    }
    vector<int>ans;
    while(dp[n]){
        int k=dp[n]%10;
        dp[n]/=10;
        ans.push_back(k);
    }
    reverse(ans.begin(),ans.end());
    for(int k:ans){
        cout<<k;
    }
}