Python solution to the major element problem.