
function Main(arg)
{
  var N = arg.split("\n")[0].split(" ")[0]-0;
  var K = arg.split("\n")[0].split(" ")[1]-0;
  var p = arg.split("\n")[1].split(" ").map(v => v - 0);
  var a = new Array(N);

  for (var i = 0; i < N; i++){
    a[i] = (p[i] * (p[i] + 1) / 2)/p[i];
  }

  var max = 0;
  var val = p[0];
  for (var i = 1; i < N; i++) {
    if (val < p[i]) {
      max = i;
      val = p[i];
    }
  }

  var ans = [];
  for (var i = 0; i < K; i++) {
    var tmp = 0;
    for (var j = 0; j < K; j++){
      if (max - K + 1 + j == N) break;
      tmp += a[max - K + 1 + j];
    }
    ans.push(tmp);
  }

  console.log(ans.reduce((a,b)=>Math.max(a,b)));
  return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));