/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
Scanner in
= new Scanner
(System.
in); int n, h=0, k=0;
n = in.nextInt();
int[] A = new int [n];
for ( int i = 0; i < n; i++ ) {
A[i] = in.nextInt();
}
for ( int i = 0; i < n; i++ ) {
if ( A[n-1] == A[i] )
{
int t = 1;
for ( int j = i + 1; j < n - 1; j++ )
{
if ( A[j] != A[ n - 1 - t ] )
{
k++;
}
t++;
}
if ( k == 0 )
{
h = i;
break;
}
else k = 0;
}
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnV0aWwuU2Nhbm5lcjsKCi8qIE5hbWUgb2YgdGhlIGNsYXNzIGhhcyB0byBiZSAiTWFpbiIgb25seSBpZiB0aGUgY2xhc3MgaXMgcHVibGljLiAqLwpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uCgl7CgkJU2Nhbm5lciBpbiA9ICBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwoJCWludCBuLCBoPTAsIGs9MDsKCQluID0gaW4ubmV4dEludCgpOwogICAgCWludFtdIEEgPSBuZXcgaW50IFtuXTsKCQlmb3IgKCBpbnQgaSA9IDA7IGkgPCBuOyBpKysgKSB7CiAgICAJCUFbaV0gPSBpbi5uZXh0SW50KCk7CgkJfQoJCWZvciAoIGludCBpID0gMDsgaSA8IG47IGkrKyApIHsKICAgIAkJaWYgKCBBW24tMV0gPT0gQVtpXSApIAogICAgCQl7CiAgICAgICAgICAgIAlpbnQgdCA9IDE7CiAgICAgICAgICAgIAlmb3IgKCBpbnQgaiA9IGkgKyAxOyBqIDwgbiAtIDE7IGorKyApIAogICAgICAgICAgICAJewogICAgICAgICAgICAJCWlmICggQVtqXSAhPSBBWyBuIC0gMSAtIHQgXSApCiAgICAgICAgICAgIAkJewogICAgICAgICAgICAgICAgICAgIAlrKys7CiAgICAgICAgICAgICAgICAJfQogICAgICAgICAgICAgICAgCXQrKzsKICAgICAgICAJCX0KICAgICAgICAgICAgCWlmICggayA9PSAwICkgCiAgICAgICAgICAgIAl7CiAgICAgICAgICAgIAkJaCA9IGk7CiAgICAgICAgICAgICAgICAJYnJlYWs7CiAgICAgICAgICAgIAl9CiAgICAgICAgICAgIAllbHNlIGsgPSAwOwogICAgICAgIAl9CiAgICAJfQogICAgCVN5c3RlbS5vdXQucHJpbnQoaCk7Cgl9Cn0=