using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;

namespace ReadWriteTemplate
{
    public static class Solver
    {
        private static void SolveCase()
        {
            int n = ReadInt();
            long c = ReadLong();
            long[] h = ReadLongArray();

            var ch = new ConvexHullTrickBinSearch(n);
            ch.Add(-2 * h[0], h[0] * h[0]);
            long ans = 0;
            for (int i = 1; i < n; i++)
            {
                ans = ch.Query(h[i]) + h[i] * h[i] + c;
                ch.Add(-2 * h[i], ans + h[i] * h[i]);
            }

            Writer.WriteLine(ans);
        }

        public class ConvexHullTrickBinSearch
        {
            // = k * x + b
            private long[] k;

            private long[] b;

            private int t;

            public ConvexHullTrickBinSearch(int n)
            {
                k = new long[n];
                b = new long[n];

                t = 0;
            }

            public void Add(long kn, long bn)
            {
                while (t >= 2 && Remove(kn, bn))
                {
                    t--;
                }
                k[t] = kn;
                b[t] = bn;
                t++;
            }

            public long Query(long x)
            {
                int l = 0;
                int r = t - 1;
                while (l < r)
                {
                    int m = (l + r) / 2;
                    if (Func(m, x) > Func(m + 1, x))
                    {
                        l = m + 1;
                    }
                    else
                    {
                        r = m;
                    }
                }
                return Func(l, x);
            }

            private long Func(int i, long x)
            {
                return b[i] + k[i] * x;
            }

            private bool Remove(long kn, long bn)
            {
                return (b[t - 1] - b[t - 2]) * (kn - k[t - 2]) <= (bn - b[t - 2]) * (k[t - 1] - k[t - 2]);
            }
        }

        public class ConvexHullTrickQueue
        {
            public long Ans;

            private int n;

            private long[] h;

            private long c;

            private long[] dp;

            public ConvexHullTrickQueue(int n, long[] h, long c)
            {
                this.n = n;
                this.h = h;
                this.c = c;

                Build();
            }

            private void Build()
            {
                dp = new long[n];

                int s = 0;
                int t = 1;
                int[] q = new int[n];

                for (int i = 1; i < n; i++)
                {
                    // change sign to >= ONLY here if max is needed
                    while (t - s > 1 && Func(i, q[s]) >= Func(i, q[s + 1]))
                    {
                        s++;
                    }

                    int j = q[s];

                    dp[i] = Func(i, j);

                    while (t - s > 1 && Remove(q[t - 2], q[t - 1], i))
                    {
                        t--;
                    }

                    q[t] = i;
                    t++;
                }

                Ans = dp[n - 1];
            }

            private long Func(int i, int j)
            {
                return dp[j] + (h[i] - h[j]) * (h[i] - h[j]) + c;
            }

            private bool Remove(int i1, int i2, int i3)
            {
                return (dp[i2] + h[i2] * h[i2] - dp[i1] - h[i1] * h[i1]) * (-h[i3] + h[i1]) <=
                       (dp[i3] + h[i3] * h[i3] - dp[i1] - h[i1] * h[i1]) * (-h[i2] + h[i1]);
            }
        }

        public static void Solve()
        {
#if DEBUG
            var sw = Stopwatch.StartNew();
#endif

            SolveCase();

            /*int T = ReadInt();
            for (int i = 0; i < T; i++)
            {
                Writer.Write("Case #{0}: ", i + 1);
                SolveCase();
            }*/

#if DEBUG
            sw.Stop();
            Console.WriteLine($"{sw.ElapsedMilliseconds} ms");
#endif
        }

        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if DEBUG
            //Reader = Console.In; Writer = Console.Out;
            Reader = File.OpenText("input.txt"); Writer = File.CreateText("output.txt");
#else
            Reader = Console.In; Writer = Console.Out;
#endif

            // Solve();
            Thread thread = new Thread(Solve, 64 * 1024 * 1024);
            thread.CurrentCulture = CultureInfo.InvariantCulture;
            thread.Start();
            thread.Join();

            Reader.Close();
            Writer.Close();
        }

        public static IOrderedEnumerable<TSource> OrderByWithShuffle<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
        {
            return source.Shuffle().OrderBy(keySelector);
        }

        public static T[] Shuffle<T>(this IEnumerable<T> source)
        {
            T[] result = source.ToArray();
            Shuffle(result);
            return result;
        }

        private static void Shuffle<T>(IList<T> array)
        {
            Random rnd = new Random();
            for (int i = array.Count - 1; i >= 1; i--)
            {
                int k = rnd.Next(i + 1);
                T tmp = array[k];
                array[k] = array[i];
                array[i] = tmp;
            }
        }

        #region Read/Write

        private static TextReader Reader;

        private static TextWriter Writer;

        private static Queue<string> CurrentLineTokens = new Queue<string>();

        private static string[] ReadAndSplitLine()
        {
            return Reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }

        public static string ReadToken()
        {
            while (CurrentLineTokens.Count == 0)
                CurrentLineTokens = new Queue<string>(ReadAndSplitLine());
            return CurrentLineTokens.Dequeue();
        }

        public static string ReadLine()
        {
            return Reader.ReadLine();
        }

        public static int ReadInt()
        {
            return int.Parse(ReadToken());
        }

        public static long ReadLong()
        {
            return long.Parse(ReadToken());
        }

        public static double ReadDouble()
        {
            return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
        }

        public static int[] ReadIntArray()
        {
            return ReadAndSplitLine().Select(int.Parse).ToArray();
        }

        public static long[] ReadLongArray()
        {
            return ReadAndSplitLine().Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
        }

        public static int[][] ReadIntMatrix(int numberOfRows)
        {
            int[][] matrix = new int[numberOfRows][];
            for (int i = 0; i < numberOfRows; i++)
                matrix[i] = ReadIntArray();
            return matrix;
        }

        public static string[] ReadLines(int quantity)
        {
            string[] lines = new string[quantity];
            for (int i = 0; i < quantity; i++)
                lines[i] = Reader.ReadLine().Trim();
            return lines;
        }

        public static void WriteArray<T>(IEnumerable<T> array)
        {
            Writer.WriteLine(string.Join(" ", array));
        }

        #endregion
    }
}


Measured memory_bytes: 38492