import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) from itertools import accumulate n, k, *a = map(int, read().split()) cumsum = [0] + list(accumulate(a)) ans = -float('inf') for kk in range(1, k + 1): for bf, af in zip(cumsum, cumsum[kk:]): ans = max(ans, af - bf) print(ans)