Số dư lớn nhất


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 1G

Problem type

Cho dãy số nguyên $a_1,a_2,...,a_N$ phân biệt đôi một. An lấy hai số nguyên $a_i$ và $a_j$ bất kì từ dãy rồi lấy $a_i\ mod\ a_j$. Hãy cho biết kết quả lớn nhất An có thể thu được là bao nhiêu?

Lưu ý: phép $mod$ là phép chia lấy dư.

Dữ liệu

  • Dòng duy nhất chứa số nguyên $N$ $(1 \le N \le 10^5)$;
  • Dòng tiếp theo chứa $N$ số nguyên $a_i$ $(1<a_i \le 10^9)$.

Kết quả

  • Kết quả bài toán.

Ví dụ

Ví dụ 1

input

6
1 2 4 7 5 6

output

6

Comments

There are no comments at the moment.