def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    sa, sb = [0 for i in range(n+1)], [0 for i in range(n+1)]
    for i in range(1, n+1):
        sa[i] = sa[i-1] + a[i-1]
        sb[i] = sb[i-1] + max(0, a[i-1])

    ans = 0
    for i in range(n-k+1):
        ss = sb[i] + sb[n] - sb[i+k]
        s1 = sa[i+k] - sa[i] + ss
        ans = max(ans, s1, ss)

    print(ans)


if __name__ == '__main__':
    main()
