ALGORITHM

Revision en1, by ken_love_rin, 2015-09-23 17:26:03

Help me. thanks.

Give a sequence of numbers a1,a2...an. (n<=2*10^5, 0<a[i]<=10^6). Find the maximum of (a[i] mod a[j]) a[i]>=a[j], (1<=i,j<=n).

For example

input

3 2 4 5

output 1 ( 5 mod 4)

intput

3 15 22 44

output

14 ( 44 mod 15 ).

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English ken_love_rin 2015-09-23 17:26:03 278 Initial revision (published)