import Control.Monad (replicateM,foldM)
import Data.Array.IO (IOArray,readArray,writeArray,newListArray)

data CalcState = CalcState {
    maximumSum :: Int,
    currentSum :: Int,
    queue :: IOArray Int Int,
    queueLength :: Int,
    queueEnd :: Int
}

main = do
    [n,k] <- getLine >>= return . map read. words
    if all (==0) [n,k] then return () else do
        state <- replicateM k (getLine >>= return . read) >>= setup
        state <- foldM update' state [k+1..n]
        print (maximumSum state)

        main

    where
    update' state _ = getLine >>= return . read >>= update state


setup :: [Int] -> IO CalcState
setup ns = do
    let
        ql = length ns
        s = sum ns
    q <- newListArray (0,ql-1) ns
    return (CalcState s s q ql 0)

update :: CalcState -> Int -> IO CalcState
update (CalcState ms cs q ql qe) n = do
    r <- readArray q qe
    writeArray q qe n
    let
        cs' = cs - r + n
    return (CalcState (max ms cs') cs' q ql ((qe+1)`mod`ql))