For this Question: Given an array with repeated elements, the task is to find the maximum distance between two occurrences of an element.

Note:- It is guaranteed that atleast one number is repeated.The first line of the input contains an integer N denoting the number of elements in the array, the next line contains N space separated integers.

Constraints:
1 <= N <= 100000
1 <= Arr[i] <= 10^9For each test case in new line print the Maximum distance between two occurrences of an elementSample Input
6
1 1 2 2 2 1

Sample Output
5

Explanation:-
The index of two occurrences are:- (1, 2), (1, 6), (2, 6), (3, 4), (3, 5), (4, 5)
it can be seen that the maximum distance is between (1, 6) i. e. 5

Sample Input
5
1 1 1 1 1

Sample Output
4, I have written this Solution Code: import numpy as np
from collections import defaultdict

d=defaultdict(list)
n=input()
a=np.array([input().strip().split()]).flatten()
for i in range(len(a)):
  d[a[i]].append(i)

for i in d:
  d[i].sort()

ans=0
for i in d:
  ans=max(ans,d[i][-1]-d[i][0])
print(ans), In this Programming Language: Python, Now tell me if this Code is compilable or not?