Find value in an array corresponding to position of max in another one [duplicate]