So, you know how to get the frequency of each value of "a" right? Try to do this on paper, and go step by step

You got the first "a" in the list let's say A1, and you got the Frequncy of A1, let's call it F1. Now, let's say you get the second "a" in the list, let's call it A2, and you get the frequency of A2, let's call it F2. How will you know between A1 and A2, which one is more frequent? Once you did that, how will you do the same thing with A1, A2 and A3. How will you do that with A1, A2, A3... An.