#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int arr[n*2];
for (int i = 0;i < n*2;i++) {
cin >> arr[i];
}
int max_value = 0;
for (int i = 0;i < n*2;i++) {
for (int j = i;j < n*2;j++) {
if (arr[i] == arr[j] && i != j) {
if (max_value < j-i-1) {
max_value = j-i-1;
}
}
}
}
cout << max_value;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: