//Problem "MinLex"
//9th Internet Olympiad, season 2007-2008
//Problem Author:  Fedor Tsarev, tsarev@rain.ifmo.ru
//Solution Author: Vladimir Ulyantsev, ulyantsev@rain.ifmo.ru

import java.io.*;
import java.util.*;

public class minlex_vu implements Runnable {
	final static String FILE = "minlex";
	
	public static void main(String[] args) {
		Locale.setDefault(Locale.US);
		new Thread(new minlex_vu()).start();
	}
	
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;
	
	int nextInt() throws IOException {
		while (st == null || !st.hasMoreElements()) {
			st = new StringTokenizer(in.readLine());
		}
		return Integer.parseInt(st.nextToken());
	}
	
	public minlex_vu() {
		try {
			in = new BufferedReader(new FileReader(FILE + ".in"));
			out = new PrintWriter(new File(FILE + ".out"));
			st = new StringTokenizer("");
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
	
	public void run() {
		try {
			solve();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			out.close();
		}
	}
	
	
	public void solve() throws IOException {
		int n = nextInt();
		int[] p = new int[n];
		int pos = -1;
		for (int i = 0; i < n; i++) {
			p[i] = nextInt();
			if (p[i] == 1) {
				pos = i;	
			}
			if (pos > -1) {
				out.print(p[i] + " ");
			}
		}
		for (int i = 0; i < pos; i++) {
			out.print(p[i] + " ");
		}
	}
	
}
