source_code: import java.io.*;
  import java.util.*;
  
  public class TaskA {
  	BufferedReader br;
  	PrintWriter out;
  	StringTokenizer stok;
  
  	String nextToken() throws IOException {
  		while (stok == null || !stok.hasMoreTokens()) {
  			String s = br.readLine();
  			if (s == null) {
  				return "-1";
  			}
  			stok = new StringTokenizer(s);
  		}
  		return stok.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());
  	}
  
  	char nextChar() throws IOException {
  		return (char) (br.read());
  	}
  
  	String nextLine() throws IOException {
  		return br.readLine();
  	}
  
  	void solve() throws IOException {
  		int n = nextInt();
  		int[] a = new int[n];
  		for (int i = 0; i < n; i++) {
  			a[i] = nextInt();
  		}
  		Arrays.sort(a);
  		a[n - 1] = a[n - 1] == 1 ? 2 : 1;
  		Arrays.sort(a);
  		for (int i = 0; i < n; i++) {
  			out.print(a[i]);
  			out.print(' ');
  		}
  	}
  
  	void run() throws IOException {
  		// br = new BufferedReader(new FileReader("taska.in"));
  		// out = new PrintWriter("taska.out");
  		// br = new BufferedReader(new FileReader("input.txt"));
  		// out = new PrintWriter("output.txt");
  		br = new BufferedReader(new InputStreamReader(System.in));
  		out = new PrintWriter(System.out);
  		solve();
  		br.close();
  		out.close();
  	}
  
  	public static void main(String[] args) throws IOException {
  		// Locale.setDefault(Locale.US);
  		new TaskA().run();
  	}
  }