output_description: Print the maximum total number of monsters the heroes can defeat.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 ... A_{N+1}
      B_1 B_2 ... B_N
attempt: N = int(input())
  
  monsters = list(map(int, input().split()))
  powers = list(map(int, input().split()))
  
  # dp[i] = i番目の街のモンスターを最も多く倒せる数
  dp = [0 for _ in range(N + 1)]
  
  # 初期条件
  # 勇者パワーの方が少ない場合その数しか倒せない
  # モンスター数の方が少ない場合もその数しか倒せない
  # print(f"powers: {powers}")
  dp[N] = min(monsters[N], powers[N - 1])
  # 勇者の火力を減らしておく
  powers[N - 1] -= dp[N]
  # Nから-1ずつ下がって0まで処理する
  for i in range(N - 1, 0, -1):
      # print(f"powers: {powers}")
      # i番目の倒せる最大数を求める
      # i番目の勇者がi+1番目のモンスターを倒して残った火力 + i-1番目の勇者の火力と
      # i番目のモンスター数の内、少ない方が倒せる最大数になる
      dp[i] = min(powers[i] + powers[i - 1], monsters[i])
      # i-1番目の勇者の火力を減らしておく
      # ただしi番目の勇者で十分倒せる火力の場合何も減らさない
      powers[i - 1] -= max(dp[i] - powers[i], 0)
  
  # print(f"powers: {powers}")
  # 0番目の勇者の倒せる最大数を求める
  dp[0] = min(powers[0], monsters[0])
  
  print(sum(dp))
  
problem_description: Statement
  
  There are N+1 towns. The i-th town is being attacked by A_i monsters.
  
  We have N heroes. The i-th hero can defeat monsters attacking the i-th or
  (i+1)-th town, for a total of at most B_i monsters.
  
  What is the maximum total number of monsters the heroes can cooperate to
  defeat?
samples: [{"input": "2\n    3 5 2\n    4 5", "output": "9\n    \n\nIf the heroes choose the monsters to defeat as follows, they can defeat nine\nmonsters in total, which is the maximum result.\n\n  * The first hero defeats two monsters attacking the first town and two monsters attacking the second town.\n  * The second hero defeats three monsters attacking the second town and two monsters attacking the third town.\n\n* * *"}, {"input": "3\n    5 6 3 8\n    5 100 8", "output": "22\n    \n\n* * *"}, {"input": "2\n    100 1 1\n    1 100", "output": "3"}]