Mukesh has given an array π1,π2,β¦,ππ to Mahesh. Mahesh can remove at most one subsegment from it. The remaining elements should be pairwise distinct.

In other words, at most one time Mahesh can choose two integers π and π (1β€πβ€πβ€π) and delete integers ππ,ππ+1,β¦,ππ from the array. The remaining elements should be pairwise distinct.

**Input:**
The first line contains a single integer π β the number of elements in the given array.
The next line contains π spaced integers π1,π2,β¦,ππ β the elements of the array.
**Output:**
Print the output, the minimum size of the subsegment to remove to make all elements of the array pairwise distinct. If no subsegment needs to be removed, print 0

#include <stdio.h> int compare(const void *a, const void *b) {if(*(int *)a == *(int *)b){return 1;} else{return 0;} } int main() {int n,i,j,count=0; scanf("%d",&n); int arr[n]; for(i=0;i < n;i++){ scanf("%d",&arr[i]);} for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(compare(&arr[i],&arr[j])) count++;} } printf("%d",count); return 0; }

**INPUT_1:**

5

3 4 2 4 9

**OUTPUT:**

1

**INPUT_2:**

4

1 1 2 2

**OUTPUT:**

2

**ILLUSTRATION:**