source_code: import static java.lang.Math.*;
  import static java.lang.System.currentTimeMillis;
  import static java.lang.System.exit;
  import static java.lang.System.arraycopy;
  import static java.util.Arrays.sort;
  import static java.util.Arrays.binarySearch;
  import static java.util.Arrays.fill;
  import java.util.*;
  import java.io.*;
  
  public class Main {
  
  	public static void main(String[] args) throws IOException {
  		try {
  			if (new File("input.txt").exists())
  				System.setIn(new FileInputStream("input.txt"));
  		} catch (SecurityException e) {
  		}
  		new Main().run();
  	}
  
  	BufferedReader in;
  	PrintWriter out;
  	StringTokenizer st = new StringTokenizer("");
  
  	private void run() throws IOException {
  		in = new BufferedReader(new InputStreamReader(System.in));
  		out = new PrintWriter(System.out);
  
  		int n = nextInt();
  		int m[] = new int[n];
  		for(int i = 0; i < n; i++)
  			m[i] = nextInt();
  		sort(m);
  		m[n - 1] = m[n - 1] != 1 ? 1 : 2;
  		sort(m);
  		for(int i = 0; i < n; i++){
  			if(i != 0) out.print(" ");
  			out.print(m[i]);
  		}
  		out.println();
  		in.close();
  		out.close();
  	}
  
  	void chk(boolean b) {
  		if (b)
  			return;
  		System.out.println(new Error().getStackTrace()[1]);
  		exit(999);
  	}
  	void deb(String fmt, Object... args) {
  		System.out.printf(Locale.US, fmt + "%n", args);
  	}
  	String nextToken() throws IOException {
  		while (!st.hasMoreTokens())
  			st = new StringTokenizer(in.readLine());
  		return st.nextToken();
  	}
  	int nextInt() throws IOException {
  		return Integer.parseInt(nextToken());
  	}
  	long nextLong() throws IOException {
  		return Long.parseLong(nextToken());
  	}
  	double nextDouble() throws IOException {
  		return Double.parseDouble(nextToken());
  	}
  	String nextLine() throws IOException {
  		st = new StringTokenizer("");
  		return in.readLine();
  	}
  	boolean EOF() throws IOException {
  		while (!st.hasMoreTokens()) {
  			String s = in.readLine();
  			if (s == null)
  				return true;
  			st = new StringTokenizer(s);
  		}
  		return false;
  	}
  }
  