loop do
  n, k = gets.split.map(&:to_i)
  
  break if n == 0 && k == 0
  
  arr, ans = [], 0
  
  n.times do
   arr << gets.to_i
  end
  
  (n - 2).times do |i|
    ans = [ans, arr[i] + arr[i + 1] + arr[i + 2]].max
  end
  
  puts ans
end