If you have all the values as a list, largest first you could try a very simple from MHUPPS example
(setq lst (car lst))
of
(setq lst (nth 0 lst))
Both set the variable lst to the first value in that list and deletes all the others
I think RonJonp offered a solution that does the same , Replace (print with (setq maxvalue