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.
Example:
Input:
5
1 2 3 4 5
Output:
4
I just need the program for this in python language
Answers
Answered by
2
Answer:
n=int(input())
l=list(map(int,input().split()))
maximum=0
for i in range(0,n-1):
for j in range(1,n):
m=l[i]%l[j]
if m>maximum:
maximum=m
print(maximum,end='')
Explanation:
Answered by
0
Answer:
Explanation:
n=int(input())
f=[int(i) for i in input().split()]
max=0
for i in range(n):
for j in range(n):
k=f[i]%f[j]
if(k>max):
max=k
print(max,end="")
Similar questions
Science,
5 months ago
Math,
5 months ago
Social Sciences,
5 months ago
Chemistry,
11 months ago
Social Sciences,
11 months ago
Science,
1 year ago