lambda1@tg says to YSITD
That is, of course, assumming the set {a1, a2... an} is a totally-ordered set