// Arup Guha
// 9/16/2012
// Solution to 2009 MCPC Problem E: Duplicate Removal

import java.util.*;

public class e {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();

		// Process all cases.
		while (n != 0) {

			// Just go in order - don't print if current is the previous.
			int last = -1;
			for (int i=0; i<n; i++) {
				int item = stdin.nextInt();
				if (item != last)
					System.out.print(item+" ");
				last = item;
			}

			// End case and go to next.
			System.out.println("$");
			n = stdin.nextInt();
		}
	}
}