add selection of max and min in array