// Arup Guha
// 10/15/2021
// Solution to 2021 UCF Locals Qualifying Round Problem: Heavy Numbers

import java.util.*;

public class ranking {

	public static void main(String[] args) {
	
		// Read input.
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		
		// Get ready to read in input.
		HashMap<String,Integer> map = new HashMap<String,Integer>();
		String[] teamList = new String[n];
		int id = 0;
		
		// Read through schools.
		for (int i=0; i<n; i++) {
		
			// Read in the team, update the map, if necessary.
			teamList[i] = stdin.next();
			if (!map.containsKey(teamList[i])) 
				map.put(teamList[i], id++);
		}
		
		// Store schools here.
		school[] sList = new school[map.size()];
		
		// Create the objects for the schools.
		for (String s: map.keySet()) sList[map.get(s)] = new school(s);
		
		// Go through the data again, updating ranks, numteams...
		for (int i=0; i<n; i++) {
			int idx = map.get(teamList[i]);
			sList[idx].sumRanks += (i+1);
			sList[idx].numTeams++;
		}
		
		// Sort it and print.
		Arrays.sort(sList);
		for (int i=0; i<sList.length; i++)
			System.out.println(sList[i].name);
		
	}
	
}

class school implements Comparable<school> {

	public String name;
	public int sumRanks;
	public int numTeams;
	
	public school(String n) {
		name = n;
		sumRanks = 0;
		numTeams = 0;
	}
	
	// This does the proper comparison between two postive fractions.
	public int compareTo(school other) {
		return this.sumRanks*other.numTeams - this.numTeams*other.sumRanks;
	}
}