You could do it with a second array we'll call "list" and has a size of (0,3,1).
So you'd first loop over your array and check if any spot is equal to that certain value. If it is then make the list one longer and store the distance, and the current x and y in the array.
After that use the sort action on list and the first value will be the closest and the last will be the furthest.
--- set list size to (0,3,1)
Array: for each xy
Array: current value=certainValue
--- list push 0 front
--- set list at (0,0) to distance(X,y, array.curx, array.cury)
--- set list at (0,1) to array.curx
--- set list at (0,2) to array.cury
--- list: sort
Then the closest X and y would be:
And the furthest: