How to find maximum and minimum values

sweet thanks robtilaart