There are N people P1, P2, P3, …, PN having F1, F2, F3, …, FN Facebook friends, respectively. The solution to this problem is finding k = Fi%Fj such that it is maximum over all valid i,j. Constraints:
2 <= N <= 105
1 <= Ai <= 109 for each i
Input Format:
The first line contains an integer N
The second line contains N space-separated integers F1, F2, F3, …, FN
Output Format:
Print in a single line the output which is k, the solution to this problem.
Answers
Answered by
12
Answer:
n=int(input())
a=[int(x) for x in input().split(" ")]
l=len(a)
y=[]
for i in range(0,l):
for j in range(0,l):
if(i!=j):
y.append(a[i]%a[j])
y.sort()
l2=len(y)
print(y[l2-1],end='')
Explanation:
Answered by
5
Answer:
Explanation:
n=int(input())
l=sorted(list(map(int,input().split())))
print(l[-2],end="")
Similar questions