def putin():
    return map(int, input().split())


def sol():
    n = int(input())
    C = list(putin())
    B = list(putin())
    q = int(input())
    x = int(input())
    min_arr = [x]
    min_part = [x]
    for elem in B:
        min_arr.append(min_arr[-1] + elem)
        min_part.append(min_arr[-1] + min_part[-1])
    if min_part[0] > C[0]:
        return 0
    answer = {}
    for elem in range(max(0, min_part[0]), C[0] + 1):
        answer[elem] = 1
    print(answer)
    for k in range(1, n):
        new_answer = {}
        for elem in answer:
            for j in range(C[k] + 1):
                if elem + j >= min_part[k]:
                    if elem + j in new_answer:
                        new_answer[elem + j] += answer[elem]
                    else:
                        new_answer[elem + j] = answer[elem]
        answer = new_answer.copy()
    return sum([answer[key] for key in answer])


print(sol())
