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.

Constraints

* 3 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9
* All values in input are integers.

Input

Input is given from Standard Input in the following format:


N
A_1 A_2 ... A_N
B_1 B_2 ... B_N


Output

Print the minimum number of operations required, or `-1` if the objective cannot be achieved.

Examples

Input

3
1 1 1
13 5 7


Output

4


Input

4
1 2 3 4
2 3 4 5


Output

-1


Input

5
5 6 5 2 1
9817 1108 6890 4343 8704


Output

25
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()