I think the problem is that; in the line
with the specification "loca[i]", you try to use an array element
with an index number 0... An array cant have 0th element...
Its because, at the beginning of your for loop, your index i is
starting with the value 0...
I think, somehow you must avoid using 0th element in the array..
Then the problem drops automatically
Have a beautiful day..