Find min and max value in an array