output_description: Print the minimum number of operations required, or `-1` if the objective
  cannot be achieved.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 ... A_N
      B_1 B_2 ... B_N
attempt: import glob
  
  
  # 問題ごとのディレクトリのトップからの相対パス
  REL_PATH = "ABC\\AGC\\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):
  
          ring_len = int(self.input_data())
          first_ring = [int(i) for i in self.input_data().split()]
          now_ring = [int(i) for i in self.input_data().split()]
  
          count = 0
          result = True
          loop = True
  
          while loop:
  
              result = True
              loop = False
              i = 0
  
              while i < ring_len:
                  if first_ring[i] == now_ring[i]:
                      i += 1
                      continue
  
                  result = False
  
                  if first_ring[i] > now_ring[i]:
                      break
                  if i != 0:
                      prv = i - 1
                  else:
                      prv = ring_len - 1
  
                  if i != ring_len - 1:
                      nxt = i + 1
                  else:
                      nxt = 0
  
                  if now_ring[i] > now_ring[prv] + now_ring[nxt]:
                      loop = True
                      tmp = int(
                          (now_ring[i] - first_ring[i]) / (now_ring[prv] + now_ring[nxt])
                      )
                      if tmp == 0:
                          loop = False
                          break
                      loop = True
                      now_ring[i] -= (now_ring[prv] + now_ring[nxt]) * tmp
                      count += tmp
                      i = i - 2
                      if i < -1:
                          i += ring_len
  
                  i += 1
  
              if result:
                  loop = False
  
          if result:
              print(str(count))
          else:
              print("-1")
  
  
  solver = C(REL_PATH)
  solver.exec_resolve()
  
problem_description: Statement
  
  There are N positive integers arranged in a circle.
  
  Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For
  this objective, he will repeatedly perform the following operation:
  
    * Choose an integer i such that 1 \leq i \leq N.
    * Let a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c.
  
  Here the 0-th number is the N-th number, and the (N+1)-th number is the 1-st
  number.
  
  Determine if Takahashi can achieve his objective. If the answer is yes, find
  the minimum number of operations required.
samples: [{"input": "3\n    1 1 1\n    13 5 7", "output": "4\n    \n\nTakahashi can achieve his objective by, for example, performing the following\noperations:\n\n  * Replace the second number with 3.\n  * Replace the second number with 5.\n  * Replace the third number with 7.\n  * Replace the first number with 13.\n\n* * *"}, {"input": "4\n    1 2 3 4\n    2 3 4 5", "output": "-1\n    \n\n* * *"}, {"input": "5\n    5 6 5 2 1\n    9817 1108 6890 4343 8704", "output": "25"}]