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.

def f(x ,nums , i , n,l):
    if i > n:
        return 0
    return ( x % nums[l] ) + f( (x % nums[l]) , nums ,i+1,n,l+1)



n = int( input() )

nums = list()
maximum = -1

for i in range(n):
    nums.append( int( input() ) )


maxNum = -1
for num in nums:
    if num > maxNum:
        maxNum = num

x = 1
while x <= maxNum:
    if f(x , nums ,1 ,n,0) > maximum:
        maximum = f(x , nums ,1 ,n,0)
    x = x + 1

print(maximum)
    
