Array
면접 대비시간 제한3초메모리 제한256 MB
배열을 임의로 재배열해 x = x mod a_i를 반복한 뒤 얻을 수 있는 마지막 값의 최댓값을 구한다.
문제
You are given an array . Let , and for each from to .
Suppose that we can rearrange in any way. What is the largest possible value of we can obtain?
입력
The first line contains an integer --- the size of the array ().
The second line containing integers ().
출력
Print one integer --- the largest possible value of .