#include <cstdio>
#include <cstring>
#include <cstdint>
#include <cstdlib>
#include <cstddef>
#include <cinttypes>

#include <type_traits>
#include <limits>

/* FastIO by rsk0315 (last update: 2018/02/21 00:36) */

namespace FastIn {
  static constexpr size_t BUF_SIZE=1<<17, INT_LEN=24, FLT_LEN=400;
  static char buf[BUF_SIZE|1]={}, *pos=buf, *endbuf=nullptr;
  FILE *fin;

  inline bool rebuffer() {
    // returns true <=> there is at least one unread character
    size_t rest=endbuf-pos;
    if (buf+rest > pos) {
      // buf[:pos] and buf[-pos:] are overlapping, which std::memcpy()
      // causes undefined behavior.
      return true;
    }

    std::memcpy(buf, pos, rest); 
    pos = buf;
    size_t len=std::fread(pos+rest, 1, BUF_SIZE-rest, fin);
    *(endbuf = buf + (rest+len)) = 0;

    return *pos;
  }

  inline bool scan(char &in) {
    if ((in = *pos)) {
      ++pos;
      return true;
    }

    return rebuffer() && (in = *pos++);
  }

  inline bool scan(char *in) {
    if ((*in = *pos) == 0) {
      if (rebuffer() && (*in = *pos) == 0) {
        return false;
      }
    }
    ++in;
    while (true) {
      if ((*in = *pos++) == 0) {
        if (rebuffer() && (*in = *pos++) == 0) {
          return true;
        }
      }
      ++in;
    }
  }

  inline bool scan(double &in) {
    if (pos + FLT_LEN >= endbuf && !rebuffer()) {
      in = 0.0;
      return false;
    }

    char *tmp;
    in = std::strtod(pos, &tmp);
    pos = tmp;
    return true;
  }

  template <class Int>
  inline bool scan(Int &in) {
    in = 0;

    // assume that no redundant whitespace appears
    if (pos + INT_LEN >= endbuf && !rebuffer()) {
      return false;
    }

    if (std::is_signed<Int>::value) {
      if (*pos == '-') {
        in = ~*++pos+'1';
        while (*++pos >= '0') {
          in = in*10 + ~*pos+'1';
        }
        ++pos;
        return true;
      }
    }

    // assume that numbers are separated by the character whose value is
    // less than '0' (e.g. whitespaces, newlines)
    do {
      in = in*10 + *pos-'0';
    } while (*++pos >= '0');
    ++pos;
    return true;
  }

  inline bool eat() {
    if (*pos > ' ') {
      return true;
    }

    do {
      if (*pos == 0 && !rebuffer()) {
        return false;
      }
    } while (*++pos <= ' ');

    return true;
  }

  inline bool eat(char ch) {
    if (*pos == ch) {
      return true;
    }

    do {
      if (*pos == 0 && !rebuffer()) {
        return false;
      }
    } while (*++pos != ch);

    return true;
  }

  class Scanner {
    bool rebuffer() {
      return FastIn::rebuffer();
    }

  public:
    Scanner(FILE *fin=stdin) {
      FastIn::fin = fin;
      endbuf = pos + std::fread(buf, 1, BUF_SIZE, fin);
    }

    template <class T>
    inline bool scan(T &in) {
      return FastIn::scan(in);
    }

    template <class First, class... Rest>
    inline bool scan(First &in, Rest &...ins) {
      return scan(in) && scan(ins...);
    }
  };
}

// end of Fast IO

#include <cstdio>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <type_traits>
#include <limits>
#include <tuple>
#include <deque>

template <class Tp>
class lines {
  // assuming monotonicity
  std::deque<std::pair<Tp, Tp>> lines{{Tp(sqrt(std::numeric_limits<Tp>::max())-1), 0}};

public:
  void append(Tp a, Tp b) {
    Tp a0, b0, a1, b1;
    std::tie(a1, b1) = lines.back();
    while (lines.size() > 1) {
      std::tie(a0, b0) = lines[lines.size()-2];
      if ((a1-a)*(b1-b0) < (a0-a1)*(b-b1)) break;
      lines.pop_back();
      a1 = a0;
      b1 = b0;
    }
    lines.emplace_back(a, b);
  }

  Tp min_at(Tp x) {
    Tp a0, b0, a1, b1;
    Tp y0, y1;
    std::tie(a0, b0) = lines[0];
    y0 = a0*x + b0;
    while (lines.size() > 1) {
      std::tie(a1, b1) = lines[1];
      y1 = a1*x + b1;
      if (y0 < y1) break;
      lines.pop_front();
      a0 = a1;
      b0 = b1;
      y0 = y1;
    }
    return y0;
  }
};

FastIn::Scanner cin;

int main() {
  size_t N;
  uintmax_t C;
  cin.scan(N, C);

  std::vector<uintmax_t> h(N);
  for (auto& hi: h) cin.scan(hi);

  lines<intmax_t> cht;

  std::vector<uintmax_t> dp(N);
  for (size_t i = 0; i+1 < N; ++i) {
    cht.append(-2*intmax_t(h[i]), h[i]*h[i]+dp[i]);
    dp[i+1] = cht.min_at(h[i+1]) + h[i+1]*h[i+1] + C;
  }

  printf("%ju\n", dp[N-1]);
}


Measured memory_bytes: 5632