source_code: import java.io.OutputStream;
  import java.io.PrintWriter;
  import java.util.AbstractList;
  import java.io.Writer;
  import java.util.List;
  import java.io.IOException;
  import java.util.Arrays;
  import java.util.InputMismatchException;
  import java.math.BigInteger;
  import java.io.InputStream;
  
  /**
   * Built using CHelper plug-in
   * Actual solution is at the top
   * @author Egor Kulikov (egor@egork.net)
   */
  public class Main {
  	public static void main(String[] args) {
  		InputStream inputStream = System.in;
  		OutputStream outputStream = System.out;
  		InputReader in = new InputReader(inputStream);
  		OutputWriter out = new OutputWriter(outputStream);
  		TaskA solver = new TaskA();
  		solver.solve(1, in, out);
  		out.close();
  	}
  }
  
  class TaskA {
  	public void solve(int testNumber, InputReader in, OutputWriter out) {
  		int size = in.readInt();
  		int[] array = IOUtils.readIntArray(in, size);
  		Arrays.sort(array);
  		if (array[size - 1] == 1)
  			array[size - 1] = 2;
  		else
  			array[size - 1] = 1;
  		Arrays.sort(array);
  		out.printLine(Array.wrap(array).toArray());
  	}
  }
  
  class InputReader {
  
  	private InputStream stream;
  	private byte[] buf = new byte[1024];
  	private int curChar;
  	private int numChars;
  
  	public InputReader(InputStream stream) {
  		this.stream = stream;
  	}
  
  	public int read() {
  		if (numChars == -1)
  			throw new InputMismatchException();
  		if (curChar >= numChars) {
  			curChar = 0;
  			try {
  				numChars = stream.read(buf);
  			} catch (IOException e) {
  				throw new InputMismatchException();
  			}
  			if (numChars <= 0)
  				return -1;
  		}
  		return buf[curChar++];
  	}
  
  	public int readInt() {
  		int c = read();
  		while (isSpaceChar(c))
  			c = read();
  		int sgn = 1;
  		if (c == '-') {
  			sgn = -1;
  			c = read();
  		}
  		int res = 0;
  		do {
  			if (c < '0' || c > '9')
  				throw new InputMismatchException();
  			res *= 10;
  			res += c - '0';
  			c = read();
  		} while (!isSpaceChar(c));
  		return res * sgn;
  	}
  
  	public static boolean isSpaceChar(int c) {
  		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
  	}
  
  	}
  
  class OutputWriter {
  	private final PrintWriter writer;
  
  	public OutputWriter(OutputStream outputStream) {
  		writer = new PrintWriter(outputStream);
  	}
  
  	public OutputWriter(Writer writer) {
  		this.writer = new PrintWriter(writer);
  	}
  
  	public void print(Object...objects) {
  		for (int i = 0; i < objects.length; i++) {
  			if (i != 0)
  				writer.print(' ');
  			writer.print(objects[i]);
  		}
  	}
  
  	public void printLine(Object...objects) {
  		print(objects);
  		writer.println();
  	}
  
  	public void close() {
  		writer.close();
  	}
  
  	}
  
  class IOUtils {
  
  	public static int[] readIntArray(InputReader in, int size) {
  		int[] array = new int[size];
  		for (int i = 0; i < size; i++)
  			array[i] = in.readInt();
  		return array;
  	}
  
  	}
  
  abstract class Array<T> extends AbstractList<T> {
  
  	public static List<Integer> wrap(int...array) {
  		return new IntArray(array);
  	}
  
  	protected static class IntArray extends Array<Integer> {
  		protected final int[] array;
  
  		protected IntArray(int[] array) {
  			this.array = array;
  		}
  
  		public int size() {
  			return array.length;
  		}
  
  		public Integer get(int index) {
  			return array[index];
  		}
  
  		public Integer set(int index, Integer value) {
  			int result = array[index];
  			array[index] = value;
  			return result;
  		}
  	}
  
  	}
  
  