what's wrong with this solution
i tried many inputs program gives correct output in each case but still last condition fails to satisfy ?
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 r=new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList<Integer>();
int[] arr=new int[10]; int j=0;
int count = 1;
int nextCount=1;
for(int i=0;i<10;i++)
{
String s = r.readLine();
list.add(Integer.parseInt(s));
}
int temp = list.get(0);
int index=1;
for(int i=index;i<10;i++)
{
if(temp==list.get(i))
count++;
else
{
if(count>1)
{
arr[j] = count;
j++;
count = 1;
}
temp = list.get(i);
}
}
int max = arr[0];
for(int i=1;i<arr.length;i++)
if(max<arr[i])
max = arr[i];
System.out.println(max);
}
}