#include <bits/stdc++.h>
using namespace std;
uint64_t Square(uint64_t num) { return num * num; }
uint64_t FindCost(const vector<uint64_t> &vec, uint64_t pickup_cost, int mod) {
  vector<int> count(mod, 0);
  uint64_t cost = 0;
  for (int i = vec.size() - 1; i >= 0; i -= 1) {
    if (count[i % mod] == 0) {
      cost += vec[i];
    } else {
      cost += Square(count[i % mod] + 1) * (vec[i + mod] - vec[i]);
    }
    cost += pickup_cost;
    count[i % mod] += 1;
  }
  for (int i = 0; i < mod; i += 1) {
    cost += Square(count[i] + 1) * vec[i];
    cost += pickup_cost;
  }
  return cost;
}
int main() {
  int n;
  cin >> n;
  uint64_t pickup_cost;
  cin >> pickup_cost;
  vector<uint64_t> vec(n);
  for (auto &elem : vec) {
    cin >> elem;
  }
  uint64_t res = FindCost(vec, pickup_cost, 1);
  for (int i = 2; i <= n; i += 1) {
    res = min(res, FindCost(vec, pickup_cost, i));
  }
  cout << res << "\n";
  return 0;
}
