Gửi bài giải
Điểm:
1,00
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
512M
Input:
stdin
Output:
stdout
Tác giả:
Dạng bài
Given an array ~a~ consisting of ~n~ elements, ~a_1, a_2, . . . , a_n~. Find the maximum value of ~a_i~ mod ~a_j~ with ~1 ≤ i, j ≤ n~ and ~a_i ≥ a_j~.
Input
The first line contains ~a~ positive integer ~n~ ~(n ≤ 10^5)~, which is the number of elements in the array ~a~.
The second line contains ~n~ values ~a_1, a_2,..., a_n~ ~(1 ≤ ai ≤ 10^6)~.
Output
A single integer is the result of the problem
Sample Input 1
9
1 2 3 4 5 6 7 8 9
Sample Ouput 1
4
Bình luận