You are given a sequence of integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub>. Let <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/8767bb4afef7bf6fc8660faf93bd6c301ca33b64.png" style="max-width: 100.0%;max-height: 100.0%;"/>, and <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/fee957ce3bd2c5eda97de1361a029a3ce8188743.png" style="max-width: 100.0%;max-height: 100.0%;"/> for 1 ≤ *i* &lt; *n*. Here, <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/f52a9a86d828a54c4bc7e70dc407e45e8e5464a6.png" style="max-width: 100.0%;max-height: 100.0%;"/> denotes the modulus operation. Find the maximum value of *f*(*x*, 1) over all nonnegative integers *x*.
The first line contains a single integer *n* (1 ≤ *n* ≤ 200000) — the length of the sequence.

The second lines contains *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">13</sup>) — the elements of the sequence.
In the first example you can choose, for example, *x* = 19.

In the second example you can choose, for example, *x* = 3 or *x* = 2.
n=int(input())
list_a=[int(z) for z in input().split()]
list_out=[int(z) for z in range(0,n)]
x=19
for i in range(0,n-1):
	list_out[i]=(x%list_a[i] + ((x%list_a[i])%list_a[i+1]))
print(max(list_out))	