Dijkstra Algorithm - Could not run sketch

Okay! Thanks for replying.
But if i called 108 instead of 109 would i then return the 109th element?
I tried and dont think its the solution. ( Did i misunderstand?)

I have tried something that is similar to the “id” you were talking about and it seems to work now.