Freezing and extreme values: from RMT to number theory