def map(array)
  arr = []
  sum, index = 0, 0
  array.each_with_index{|i, idx|
    if sum >= 0
      arr << [sum, idx - index]
      sum = i
      index = idx
    else
      sum += i
    end
  }
  arr << [sum, array.size - index] if sum > 0
  return arr
end
arr = [3, -4, 2, 7, 8, 1, 0, -7, 1, -10]
def main(input = STDIN)
  while (n, k = input.gets.split(" ").map(&:to_i)) != [0, 0]
    array = []
    n.times do
      array << input.gets.to_i
    end
    array = map(array)
    #p array
    left, right, len, sum = 0, 0, 0, 0
    while right < array.size and len + array[right][1] <= k
      sum += array[right][0]
      len += array[right][1]
      right += 1
    end
    #p [sum, left, right]
    max = 0
    while right < array.size
      max = sum if sum > max
      sum += array[right][0]
      len += array[right][1]
      while len > k and right >= left
        sum -= array[left][0]
        len -= array[left][1]
        left += 1
      end
      #p [sum, left, right]
      right += 1
    end
    puts max
  end
end
main