codeparrot/codecomplex huggingface dataset:
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class A implements Runnable {
    private MyScanner in;
    private PrintWriter out;

    private void solve() {
        int n = in.nextInt();
        int[] a = new int[n];
        int max = -1, maxp = -1;
        for (int i = 0; i < n; ++i) {
            a[i] = in.nextInt();
            if (a[i] > max) {
                max = a[i];
                maxp = i;
            }
        }
        if (max == 1) {
            for (int i = 0; i < n - 1; ++i) {
                out.print(1 + " ");
            }
            out.println(2);
            return;
        }
        a[maxp] = 1;
        Arrays.sort(a);
        for (int i = 0; i < n; ++i) {
            out.print(a[i] + " ");
        }
        out.println();
    }

    @Override
    public void run() {
        in = new MyScanner();
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    public static void main(String[] args) {
        new A().run();
    }

    static class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        private String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                    return null;
                }
            }
            return st.nextToken();
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }

        public String next() {
            return nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.lang.*;
import java.io.*;
import java.util.*;
import java.math.*;

public class A implements Runnable{
    
    
    public void run() {
        int n = nextInt();
        int[] arr = new int[n];
        boolean allOne = true;
        for (int i = 0; i < n; ++i) {
            arr[i] = nextInt();
            if (arr[i] != 1) {
                allOne = false;
            }
        }
        Arrays.sort(arr);
        if (!allOne) {
            out.print("1 ");
        }
        for (int i = 0; i < n-1; ++i) {
            out.print(arr[i] + " ");
        }
        if (allOne) {
            out.print("2");
        }
        out.println();
        out.flush();
    }
    
    private static BufferedReader br = null;
    private static PrintWriter out = null;
    private static StringTokenizer stk = null;
    
    public static void main(String[] args) {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        (new Thread(new A())).start();
    }
    
    private void loadLine() {
        try {
            stk = new StringTokenizer(br.readLine());
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    private String nextLine() {
        try {
            return br.readLine();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    
    private Integer nextInt() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Integer.parseInt(stk.nextToken());
    }
    
    private Long nextLong() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Long.parseLong(stk.nextToken());
    }
    
    private String nextWord() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return (stk.nextToken());
    }
    
    private Double nextDouble() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Double.parseDouble(stk.nextToken());
    }
    
    
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;

public class AAA {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();
        int max = a[0];
        int ind = 0;
        for (int k = 1; k < n; k++) {
            if (a[k] > max) {
                max = a[k];
                ind = k;
            }
        }
        if (max != 1) {
            a[ind] = 1;
            Arrays.sort(a);
            for (int i = 0; i < a.length - 1; i++)
                System.out.print(a[i] + " ");
            System.out.println(a[a.length - 1]);
        } else {
            a[0] = 2;
            Arrays.sort(a);
            for (int i = 0; i < a.length - 1; i++)
                System.out.print(a[i] + " ");
            System.out.println(a[a.length - 1]);
        }
    }
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.util.*;
public class A135 {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
        }
        Arrays.sort(arr);
        int[] ans = new int[n];
        
        if (arr[n-1] == 1) {
            for (int i = 0 ;i < n; i++) {
                ans[i] = arr[i];
            }
            ans[n-1] = 2;
        } else {
            ans[0] = 1;
            for (int i = 1; i < n; i++) {
                ans[i] = arr[i-1];
            }
        }
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < n; i++) {
            buf.append(ans[i]);
            if (i != n-1) buf.append(' ');
        }
        System.out.print(buf.toString());
    }
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        
        int n = Integer.parseInt(r.readLine());
        
        String[] line = r.readLine().split("[ ]+");
        
        int[] a = new int[n];
        for(int i = 0; i < n; i++)
            a[i] = Integer.parseInt(line[i]);
        
        
        Arrays.sort(a);
        
        boolean found = false;
        for(int i = 0; i < n && !found; i++)
            if(a[i] != 1)found = true;
        
        
        if(found){
            System.out.println(1);
            for(int i = 1; i < n; i++)
                System.out.println(a[i-1]);
        }else{
            for(int i = 0; i < n-1; i++)
                System.out.println(1);
            System.out.println(2);
        }
    }
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class A {

    BufferedReader in;
    StringTokenizer st;
    PrintWriter out;

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }

    int nextInt() throws Exception {
        return Integer.parseInt(next());
    }

    long nextLong() throws Exception {
        return Long.parseLong(next());
    }

    double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }

    void solve() throws Exception {
        // int min = 1;
        // int max = 1000000000;
        int n = nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();

        Arrays.sort(a);

        if (a[n - 1] == 1) {
            for (int i = 1; i < n; i++)
                out.print("1 ");
            out.print(2);
            return;
        }

        // a[0]=max;

        Arrays.sort(a);
        out.print(1);
        for (int i = 1; i < n; i++)
            out.print(" " + a[i-1]);

    }

    void run() {
        try {
            Locale.setDefault(Locale.US);
            boolean oj = System.getProperty("ONLINE_JUDGE") != null;
            Reader reader = oj ? new InputStreamReader(System.in)
                    : new FileReader("input.txt");
            Writer writer = oj ? new OutputStreamWriter(System.out)
                    : new FileWriter("output.txt");
            in = new BufferedReader(reader);
            out = new PrintWriter(writer);

            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    public static void main(String[] args) {
        new A().run();

    }

}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.Scanner;

public class Beta97B {

    static Scanner in;
    static StreamTokenizer st;
    static int n;
    static int[] a;
    static int max = 1;

    public static void main(String[] args) throws IOException {
        // in = new Scanner(System.in);
        st = new StreamTokenizer(new InputStreamReader(System.in));
        n = nextInt();
        a = new int[n];
        int ind = 0;
        for (int i = 0; i < n; ++i) {
            a[i] = nextInt();
            if (a[i] > max) {
                max = a[i];
                ind = i;
            }
        }
        if (max == 1) {
            a[0] = 2;
        } else {
            a[ind] = 1;
        }
        Arrays.sort(a);
        for (int i = 0; i < n; ++i)
            System.out.print(a[i] + " ");
    }

    private static int nextInt() throws IOException {
        st.nextToken();
        return (int) st.nval;
    }
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
//package round97;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {

	static BufferedReader bf = new BufferedReader(new InputStreamReader(
			System.in));
	static StringTokenizer st;
	static PrintWriter out = new PrintWriter(System.out);

	static String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String s = bf.readLine();
			if (s == null)
				return null;
			st = new StringTokenizer(s);
		}

		return st.nextToken();
	}

	static int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	static long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	static String nextStr() throws IOException {
		return nextToken();
	}

	static double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String[] args) throws IOException {
		int n = nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		Arrays.sort(a);
		
		for (int q = 0; q < n; q++) {
			if (a[q] != 1) {
				out.print("1");
				for (int i = 1; i < n; i++) {
					out.print(" " + a[i - 1]);
				}
				out.flush();
				return;
			}
		}
		
		for (int i = 0; i < n - 1; i++) {
			out.print("1 ");
		}
		out.println("2");
		out.flush();
		
		
	}
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;

public class A {

    void run(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        boolean dif = false;
        for(int i=0;i<n;i++)a[i]=sc.nextInt();
        Arrays.sort(a);
        if(n==1){
            System.out.println(a[0]==1?2:1);return;
        }
        int[] m = new int[n];
        for(int i=1;i<n;i++)if(a[i]!=a[i-1])dif=true;
        m[0] = 1;
        for(int i=1;i<n;i++)m[i]=a[i-1];
        if(!dif&&a[0]==1)m[n-1]++;
        
        for(int i=0;i<n;i++)System.out.print(m[i]+(i==n-1?"\n":" "));
    }
    
    public static void main(String[] args) {
        new A().run();
    }
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;


public class ProblemA {

	private void solve() throws IOException {
		Scanner stdin = new Scanner(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        
        int n = Integer.valueOf(stdin.nextInt());
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
        	p[i] = stdin.nextInt();
        }
        
        Arrays.sort(p);
        if (p[n-1] == 1) {
        	p[n-1] = 2;
        } else {
        	p[n-1] = 1;
        	out.print(p[n-1] + " ");
        	n--;
        }
        
        for (int i = 0; i < n; i++) {
        	out.print(p[i] + " ");
        }
        
        
        out.flush();
        out.close();
	}
	
	public static void main(String[] args) throws IOException {
		ProblemA solver = new ProblemA();
        solver.solve();
	}
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class A{
    public static void main(String[] args) throws Exception{
        new A().run();
    }

    void run() throws Exception{
        //Scanner sc = new Scanner(System.in);
        BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(sc.readLine());
        ArrayList<Integer> a = new ArrayList<Integer>();
        //a.add(1);
        StringTokenizer st = new StringTokenizer(sc.readLine(), " ");
        boolean allOne = true;
        for(int i = 0; i < n; i++){
            int val = Integer.parseInt(st.nextToken());
            if(val!=1)allOne = false;
            a.add(val);
        }
        if(allOne){a.remove(n-1); a.add(2);}
        else a.add(1);
        Collections.sort(a);
        System.out.print(a.get(0));
        for(int i = 1; i < n; i++)
            System.out.print(" " + a.get(i));
        System.out.println();
    }
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class A {

	final String filename = new String("A").toLowerCase();

	void solve() throws Exception {
		int n = nextInt();
		int[] a = new int[n];
		int m = -1;
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
			if (m == -1 || a[i] > a[m]) {
				m = i;
			}
		}
		if (a[m] == 1)
			a[m] = 2;
		else
			a[m] = 1;
		Arrays.sort(a);
		for (int i = 0; i < n; i++) {
			out.print(a[i] + " ");
		}

	}

	void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			// in = new BufferedReader(new FileReader("input.txt"));
			// out = new PrintWriter("output.txt");

			solve();

			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;

	String nextToken() throws Exception {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws Exception {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws Exception {
		return Double.parseDouble(nextToken());
	}

	public static void main(String[] args) {
		new A().run();
	}

}
// Problem: 135_A. Replacement
// Time complexity: nlogn

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ProblemA {

    private final BufferedReader in;
    private final PrintStream out;
    private StringTokenizer tok = new StringTokenizer("");
    private String nextLine = null;

    public static void main(String[] args) throws Exception {
        new ProblemA();
    }

    private ProblemA() throws Exception {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = System.out;
        start();
        end();
    }

    private int nextInt() {
        return Integer.parseInt(nextWord());
    }

    private String nextWord() {
        if (tok.hasMoreTokens()) {
            return tok.nextToken();
        } else {
            while (!tok.hasMoreTokens()) {
                try {
                    nextLine = in.readLine();
                    if (nextLine == null) {
                        return null;
                    } else {
                        tok = new StringTokenizer(nextLine);
                    }
                } catch (IOException ex) {
                    Logger.getLogger(ProblemA.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            return tok.nextToken();
        }
    }

    private void start() {
        int n = nextInt();
        int[] a = new int[n];
        boolean allOne = true;
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
            if (a[i] != 1) {
                allOne = false;
            }
        }
        Arrays.sort(a);
        int[] res = new int[n];
        res[0] = 1;
        for (int i = 1; i < n; i++) {
            res[i] = a[i - 1];
        }
        if (allOne) {
            for (int i = 0; i < n - 1; i++) {
                out.print(a[i] + " ");
            }
            out.print(2);
        } else {
            for (int i = 0; i < n; i++) {
                out.print(res[i] + " ");
            }
        }
    }

    private void end() {
        out.close();
    }
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.util.*;

public class Main {

  public static void main(String args[]) {
    (new Main()).solve();
  }

  void solve() {

    Scanner cin = new Scanner(System.in);

    while( cin.hasNextInt() ) {

      int n = cin.nextInt();
      int arr[] = new int[n];
      for(int i=0; i<n; ++i) {
        arr[i] = cin.nextInt();
      }

      Arrays.sort(arr);

      int ret[] = new int[n];
      ret[0] = 1;
      for(int i=0; i<n-1; ++i) { ret[i + 1] = arr[i]; }
      if( arr[n - 1] == 1 ) { ret[n - 1] = 2; }

      String glue = "";
      for(int i=0; i<n; ++i) {
        System.out.print(glue + ret[i]);
        glue = " ";
      }

      System.out.println();

    }

  }

}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.lang.*;
import java.math.BigInteger;
import java.io.*;
import java.util.*;

public class Solution implements Runnable{
    public static BufferedReader br;
    public static PrintWriter out;
    public static StringTokenizer stk;
    public static boolean isStream = true;

    public static void main(String[] args) throws IOException {
    	if (isStream) {
            br = new BufferedReader(new InputStreamReader(System.in));
        } else {
            br = new BufferedReader(new FileReader("in.txt"));
        }
        out = new PrintWriter(System.out);
        new Thread(new Solution()).start();
    }

    public void loadLine() {
        try {
            stk = new StringTokenizer(br.readLine());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }

    public String nextWord() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return stk.nextToken();
    }

    public Integer nextInt() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Integer.valueOf(stk.nextToken());
    }

    public Long nextLong() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Long.valueOf(stk.nextToken());
    }

    public Double nextDouble() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Double.valueOf(stk.nextToken());
    }
    
    public Float nextFloat() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Float.valueOf(stk.nextToken());
    }
    
    public void run() {
    	int n = nextInt();
    	int[] arr = new int[n];
    	for (int i = 0; i < n;i++) {
    		arr[i] = nextInt();
    	}
    	Arrays.sort(arr);
    	if (arr[n-1] != 1) arr[n-1] = 1;
    	else arr[n-1] = 2;
    	Arrays.sort(arr);
    	for (int i = 0; i < n; i++) {
    		out.print(arr[i]+" ");
    	}
    	out.println();
    	out.flush();
    }
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
//package round97;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;

public class A {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve()
	{
		int n = ni();
		int[] a = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = ni();
		}
		Arrays.sort(a);
		if(a[n-1] > 1){
			a[n-1] = 1;
			Arrays.sort(a);
		}else{
			a[n-1] = 2;
		}
		for(int i = 0;i < n;i++){
			if(i > 0)out.print(" ");
			out.print(a[i]);
		}
		out.println();
	}
	
	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception
	{
		new A().run();
	}
	
	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}
			
			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}
	
	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}
			
			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}
	
	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}
	
	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}
	
	
	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}