n = int(input())
a = []
for i in range(n + 1):
    a.append(int(input()))
k = int(input())

s = sum(a[1: k])
sminn = s
for i in range(1, n - k + 1):
    s -= a[i]
    s += a[i + k - 1]
    sminn = min(sminn, s)
print(sminn)
    

