Using ArrayList<int>

The code is confusing because I am not sure what you expect the sketch to do.