/* 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
{
	public static void main (String[] args) throws java.lang.Exception
	{
		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;
        	}
    	}
    	System.out.print(h);
	}
}