My code may not be the best. But as best as I can test, it's correctly calculating the longest sequence.
So I don't know why it's failing to pass the last requirement.
I would gladly appreciate any assistance as to why it's not working out.

package com.codegym.task.task08.task0812;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
/*
Longest sequence
*/
public class Solution {
public static void main(String[] args) throws IOException {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> numbers = new ArrayList<>();
ArrayList<Integer> repetitions = new ArrayList<>();
// Adding numbers to the list
for (int n = 0; n < 10; n++)
numbers.add(Integer.parseInt(reader.readLine()));
// Checking for repeated numbers
Integer sequence = 1;
for (int n = 0, nxt = 1; n < 10 && nxt < 10; n++, nxt++) {
while (!numbers.get(n).equals(numbers.get(nxt))) {
n++;
nxt++;
sequence = 1;
if (n == 8 && nxt == 9) {
repetitions.add(sequence);
break;
}
}
while (numbers.get(n).equals(numbers.get(nxt))) {
sequence++;
if (n == 8 && nxt == 9) {
repetitions.add(sequence);
break;
}
n++;
nxt++;
if (!numbers.get(n).equals(numbers.get(nxt))) {
repetitions.add(sequence);
sequence = 1;
break;
}
}
}
Collections.sort(repetitions);
System.out.println(repetitions.get(repetitions.size() - 1));
}
}