public class Solution {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        ArrayList<String> n = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            n.add(reader.readLine());
        }
        for (int i = 0; i < n.size(); i++) {
            if (n.get(i).length() < n.get(i + 1).length())
            {
                continue;
            }
            else if (n.get(i).length() > n.get(i + 1).length()) {
                System.out.println(n.get(i + 1));
                System.exit(0);
            }
        }
    }
}
Что я должен поменять, чтобы она остановилась?