Multiple values and finding the greatest

I am coding a fretta gamemode and I need to collect multiple Z positions and then I need to find the greatest. How would one do this?