# Problem C - City Savers



# input

N = int(eval(input()))

a_list = list(map(int, input().split()))

b_list = list(map(int, input().split()))



# initialization

max_monster = 0



# count

for i in range(N):

    b = b_list[i]

    if a_list[i]<=b:

        max_monster += a_list[i]

        b_list[i] -= a_list[i]

        a_list[i] = 0

    else:

        max_monster += b

        b_list[i] = 0



    b = b_list[i]

    if a_list[i+1]<=b:

        max_monster += a_list[i+1]

        a_list[i+1] = 0

    else:

        max_monster += b

        a_list[i+1] -= b_list[i]



# output

print(max_monster)

# Problem C - City Savers



# input

N = int(eval(input()))

a_nums = list(map(int, input().split()))

b_nums = list(map(int, input().split()))



# initialization

ans_monsters = 0



# count

for i in range(len(b_nums)):

    # round 1

    if b_nums[i]>=a_nums[i]:

        ans_monsters += a_nums[i]

        b_nums[i] -= a_nums[i]

    else:

        ans_monsters += b_nums[i]

        b_nums[i] = 0



    # round 2

    if b_nums[i]>0:

        if b_nums[i]>=a_nums[i+1]:

            ans_monsters += a_nums[i+1]

            a_nums[i+1] = 0

        else:

            ans_monsters += b_nums[i]

            a_nums[i+1] -= b_nums[i]



# output

print(ans_monsters)

# Problem C - City Savers
# input
N = int(eval(input()))
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
# initialization
max_monster = 0
# count
for i in range(N):
    b = b_list[i]
    if a_list[i] <= b:
        max_monster += a_list[i]
        b_list[i] -= a_list[i]
        a_list[i] = 0
    else:
        max_monster += b
        b_list[i] = 0
    b = b_list[i]
    if a_list[i + 1] <= b:
        max_monster += a_list[i + 1]
        a_list[i + 1] = 0
    else:
        max_monster += b
        a_list[i + 1] -= b_list[i]
# output
print(max_monster)

# Problem C - City Savers
# input
N = int(eval(input()))
a_nums = list(map(int, input().split()))
b_nums = list(map(int, input().split()))
# initialization
ans_monsters = 0
# count
for i in range(len(b_nums)):
    # round 1
    if b_nums[i] >= a_nums[i]:
        ans_monsters += a_nums[i]
        b_nums[i] -= a_nums[i]
    else:
        ans_monsters += b_nums[i]
        b_nums[i] = 0
    # round 2
    if b_nums[i] > 0:
        if b_nums[i] >= a_nums[i + 1]:
            ans_monsters += a_nums[i + 1]
            a_nums[i + 1] = 0
        else:
            ans_monsters += b_nums[i]
            a_nums[i + 1] -= b_nums[i]
# output
print(ans_monsters)

-a_list = list(map(int, input().split())) -b_list = list(map(int, input().split())) +a_nums = list(map(int, input().split())) +b_nums = list(map(int, input().split())) -max_monster = 0 +ans_monsters = 0 -for i in range(N): -    b = b_list[i] -    if a_list[i] <= b: -        max_monster += a_list[i] -        b_list[i] -= a_list[i] -        a_list[i] = 0 +for i in range(len(b_nums)): +    # round 1 +    if b_nums[i] >= a_nums[i]: +        ans_monsters += a_nums[i] +        b_nums[i] -= a_nums[i] -        max_monster += b -        b_list[i] = 0 -    b = b_list[i] -    if a_list[i + 1] <= b: -        max_monster += a_list[i + 1] -        a_list[i + 1] = 0 -    else: -        max_monster += b -        a_list[i + 1] -= b_list[i] +        ans_monsters += b_nums[i] +        b_nums[i] = 0 +    # round 2 +    if b_nums[i] > 0: +        if b_nums[i] >= a_nums[i + 1]: +            ans_monsters += a_nums[i + 1] +            a_nums[i + 1] = 0 +        else: +            ans_monsters += b_nums[i] +            a_nums[i + 1] -= b_nums[i] -print(max_monster) +print(ans_monsters)