
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);


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

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

  console.log(ans);
  return;
}

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