Array

아직 제출이 없습니다시간 제한3초메모리 제한256 MB

문제

You are given an array a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n. Let x_1=a_1x\_1 = a\_1, and x_i=x_i1moda_ix\_i = x\_{i - 1} \bmod a\_i for each ii from 22 to nn.

Suppose that we can rearrange a_1,,a_na\_1, \ldots, a\_n in any way. What is the largest possible value of x_nx\_n we can obtain?

입력

The first line contains an integer nn --- the size of the array (2n1052\leq n\leq 10^5).

The second line containing nn integers a_1,,a_na\_1, \ldots, a\_n (1a_i1051\leq a\_i\leq 10^5).

출력

Print one integer --- the largest possible value of x_nx\_n.