All seems to be working, but last condition not matched. I think the problem is in my second loop, it seems not taking the last value of the list. But I couldn't fix it (writes a bug that it is out of the ArrayList index).