import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            int n = sc.nextInt();
            if (n < 1 || n > 100) {
                System.out.println("Invalid input");
                return;
            }

            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = sc.next();
            }

            int maxLen = 1;
            int currentLen = 1;

            for (int i = 1; i < n; i++) {
                if (!arr[i].equals(arr[i - 1])) {
                    currentLen++;
                } else {
                    currentLen = 1;
                }
                maxLen = Math.max(maxLen, currentLen);
            }

            // If maxLen is still 1 and all elements are same → no valid subsequence
            if (maxLen == 1 && n > 1) {
                System.out.println(-1);
            } else {
                System.out.println(maxLen);
            }

        } catch (Exception e) {
            System.out.println("Invalid input");
        }
    }
}
