2 remarks:
1. n is not necessary. You can re-use i, since it is longint too. Its meaning changes to element instead of index. n is merely for clarity.
2. On my debian Linux the value is indeed 5 elements, 4 as Back and 0 as front, as you expected.
9 - 8, 0
8 - 7, 0
7 - 6, 0
6 - 5, 0
5 - 4, 0