We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

Loading...

- Practice
- Mathematics
- Number Theory
- Fibonacci GCD

# Fibonacci GCD

# Fibonacci GCD

Fibonacci numbers have the following form:

We have an array which contains elements.

We want to find .

**Input Format**

The first line contains , where denotes size of the array.

Each of the next lines contains a number: the line contains .

**Output Format**

Print a single integer — the remainder of the division of the resulting number by .

**Constraints**

**Sample Input 1**

```
3
2
3
5
```

**Sample Output 1**

```
1
```

**Explanation 1**

**Sample Input 2**

```
2
3
6
```

**Sample Output 2**

```
2
```

**Explanation 2**