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: import glob
  
  
  # 問題ごとのディレクトリのトップからの相対パス
  REL_PATH = "ABC\\135\\C"
  
  # テスト用ファイル置き場のトップ
  TOP_PATH = "C:\\AtCoder"
  
  
  class Common:
  
      problem = []
      index = 0
  
      def __init__(self, rel_path):
          self.rel_path = rel_path
  
      def initialize(self, path):
          file = open(path)
          self.problem = file.readlines()
          self.index = 0
          return
  
      def input_data(self):
          try:
              IS_TEST
              self.index += 1
              return self.problem[self.index - 1]
  
          except NameError:
              return input()
  
      def resolve(self):
          pass
  
      def exec_resolve(self):
          try:
              IS_TEST
              for path in glob.glob(TOP_PATH + "\\" + self.rel_path + "/*.txt"):
                  print("Test: " + path)
                  self.initialize(path)
                  self.resolve()
                  print("\n\n")
          except NameError:
              self.resolve()
  
  
  class C(Common):
  
      def resolve(self):
  
          N = int(self.input_data())
          monster = [int(i) for i in self.input_data().split()]
          saver = [int(i) for i in self.input_data().split()]
  
          result = 0
          remaining = 0
  
          for i in range(N):
              if saver[i] + remaining > monster[i]:
                  result += monster[i]
                  remaining = saver[i] + remaining - monster[i]
              else:
                  result += saver[i] + remaining
                  remaining = 0
  
          if remaining > monster[N]:
              result += monster[N]
          else:
              result += remaining
  
          print(str(result))
  
  
  solver = C(REL_PATH)
  solver.exec_resolve()
  
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"}]