// editor4
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        
        sc.nextLine();

        if (n < 0) {
            System.out.println("Invalid input");
            return;
        }

        String[] arr = sc.nextLine().split(" ");
        if (words.length != n) {
            System.out.println("Invalid input");
            return;
        }
        
        int max = 1, current = 1;
        for(int i = 1; i<n; i++) {
            if(arr[i].equals(arr[i-1])) {
                current = 1;
            } else {
                current++;
                if(current > max)   max = current;
            }
        }

            System.out.println(max > 1? max: -1);
        }
    }
