don't know why the last condition failed to get verified
please can anyone help point out my mistakes
package com.codegym.task.task08.task0812;
import java.io.*;
import java.util.ArrayList;
/*
Longest sequence
*/
public class Solution {
public static void main(String[] args) throws IOException {
//write your code here
BufferedReader scan= new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer>list=new ArrayList<Integer>();
ArrayList<Integer>list2=new ArrayList<Integer>();
for(int i=0;i<10;i++){
list.add(Integer.parseInt(scan.readLine()));
}
for(int a=0;a<list.size()-1;a++){
if(list.get(a).equals(list.get(a+1))){list2.add(list.get(a));}
}
int ans=1;
for(Integer a: list2){
int clone=0;
for(int i=0;i<list2.size();i++){
if(a.equals(list2.get(i))){clone++;}
if(clone>ans){ans=clone;clone=1;}
}
}
System.out.println(ans);
}
}