codeparrot/codecomplex huggingface dataset:
// Problem: 135_A. Replacement
// Time complexity: nlogn
import static java.util.Arrays.deepToString;

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

public class A {

	static int [] solve(int [] a) {
		int n = a.length;
		Arrays.sort(a);
		a[n - 1] = (a[n - 1] > 1 ? 1 : 2);
		int [] b = Arrays.copyOf(a, n);
		Arrays.sort(b);
		return b;
	}

	public static void main(String[] args) throws Exception {
		reader = new BufferedReader(new InputStreamReader(System.in));
		writer = new PrintWriter(System.out);

		setTime();
		
		int n = nextInt();
		int [] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		int [] b = solve(a);
		for (int v: b) {
			writer.print(v + " ");
		}
		
		printTime();
		printMemory();

		writer.close();
	}

	static BufferedReader reader;
	static PrintWriter writer;
	static StringTokenizer tok = new StringTokenizer("");
	static long systemTime;

	static void debug(Object... o) {
		System.err.println(deepToString(o));
	}

	static void setTime() {
		systemTime = System.currentTimeMillis();
	}

	static void printTime() {
		System.err.println("Time consumed: " + (System.currentTimeMillis() - systemTime));
	}

	static void printMemory() {
		System.err.println("Memory consumed: "
				+ (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1000 + "kb");
	}

	static String next() {
		while (!tok.hasMoreTokens()) {
			String w = null;
			try {
				w = reader.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (w == null)
				return null;
			tok = new StringTokenizer(w);
		}
		return tok.nextToken();
	}

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

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

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

	static BigInteger nextBigInteger() {
		return new BigInteger(next());
	}
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;

public class Main {
    
    public static void main(String[] args) throws Exception {
        int n = nextInt();
        
        int[] mas = new int[n];
        
        for(int i = 0; i<n; i++) {
            mas[i] = nextInt();
        }
        
        Arrays.sort(mas);
        
        if(mas[n-1] == 1) {
            for(int i = 0; i<n-1; i++) {
                out.print(1 + " ");
            }
            out.println(2);
            out.flush();
            exit();
        }
        
        out.print("1 ");
        
        for(int i = 0; i<n-1; i++) {
            out.print(mas[i] + " ");
        }
        
        out.println();
        out.flush();
    }
    
    /////////////////////////////////////////////////////////////////
    // IO
    /////////////////////////////////////////////////////////////////
    private static StreamTokenizer in;
    private static PrintWriter out;
    private static BufferedReader inB;
    
    private static boolean FILE=false;
    
    private static int nextInt() throws Exception{
        in.nextToken();
        return (int)in.nval;
    }
    
    private static String nextString() throws Exception{
        in.nextToken();
        return in.sval;
    }
    
    static{
        try {
            out = new PrintWriter(FILE ? (new FileOutputStream("output.txt")) : System.out);
            inB = new BufferedReader(new InputStreamReader(FILE ? new FileInputStream("input.txt") : System.in));
        } catch(Exception e) {e.printStackTrace();}
        in = new StreamTokenizer(inB);
    }
    /////////////////////////////////////////////////////////////////
    
    /////////////////////////////////////////////////////////////////
    // pre - written
    /////////////////////////////////////////////////////////////////
    private static void println(Object o) throws Exception {
        out.println(o);
        out.flush();
    }
    private static void exit(Object o) throws Exception {
        println(o);
        exit();
    }
    private static void exit() {
        System.exit(0);
    }
    private static final int  INF = Integer.MAX_VALUE;
    private static final int MINF = Integer.MIN_VALUE;
    //////////////////////////////////////////////////////////////////
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.* ;
import java.util.*;

import static java.lang.Math.* ;
import static java.util.Arrays.* ;

public class A {
	
	public static void main(String[] args) throws IOException {
		
		new A().solveProblem();
		
		out.close();
	}

	static Scanner in = new Scanner(new InputStreamReader(System.in));
	//static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	static PrintStream out = new PrintStream(new BufferedOutputStream(System.out));
	
	
	public void solveProblem() {		

		int n = in.nextInt() ;
		E[] get = new E[n] ;
		for( int i = 0 ; i < n ; i++ ){
			get[i] = new E(i,in.nextInt()) ;
		}
		
		sort(get) ;
		
	
		if( get[n-1].g == 1){
			get[n-1].g = 2 ;
		}else{
			get[n-1].g = 1 ;
			
		}
		sort(get) ;
		for( int i = 0 ; i < n - 1 ; i++ )
			out.print(get[i].g  +" " ) ;
		out.println(get[n-1].g) ;
		
	}
	
	class E implements Comparable<E>{
		int g ;
		int index ;
		
		public E( int index, int g){
			this.g = g ;
			this.index = index ;
		}
		
		public int compareTo( E e){
			return g - e.g ;
		}
	}

	static int[] readGet( int n ){
	  	int[] get = new int[n] ;
	  	for( int i = 0 ; i < n ; i++ )
	  		get[i] = in.nextInt();
	  	return get ;
	}
	
       
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;


public class A_135 {

    /**
     * @param args
     */
    public static void main(String[] args) {

        Scanner in=new Scanner(System.in);
        
        int n=in.nextInt();
        
        int[] mas=new int[n];
        
        for(int i=0;i<n;i++){
            mas[i]=in.nextInt();
        }
        
        Arrays.sort(mas);
        
        PrintWriter out=new PrintWriter(System.out);
        
        boolean isEd=true;
        for(int i=0;i<n;i++)
            if(mas[i]!=1){
                isEd=false;
                break;
            }
        
        if(!isEd)
            out.print('1');
        
        for(int i=0;i<n-1;i++){
            out.print(' ');
            out.print(mas[i]);
        }
        
        if(isEd)
            out.print(" 2");
        
        out.flush();
    }

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

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

public class CodeForce {
    
    private void solve() throws IOException {
        final 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) A[N-1] = 2;
        else            A[N-1] = 1;
        Arrays.sort(A);
        for(int i = 0; i < N; i++)
            System.out.print(A[i] + " ");
    }
    
    public static void main(String[] args) {
        new CodeForce().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(new FileOutputStream(new File("output.txt")));
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    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 {
        return reader.readLine();
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;

public class C {

    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        sc.nextLine();
        int[] x = new int[n];
        
        int max=0, pos=-1;
        for(int i=0; i<n; i++) {
            x[i]=sc.nextInt();
            if (max<x[i]) {
                max=x[i];
                pos=i;
            }
        }
        x[pos] = (max==1) ? 2 : 1;
        
        Arrays.sort(x);

        for(int i=0; i<n; i++) 
            System.out.print(x[i]+" ");
    }
    
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
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();
	}
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.*;
import java.util.*;
import java.util.prefs.NodeChangeEvent;
import java.math.*;

public class Main implements Runnable {
	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;
	private Random rnd;
	
	private void solve() throws IOException {
		int n = nextInt();
		
		int[] a = new int[n];
		int max = 0;
		for(int i = 0; i < n; i++) {
			a[i] = nextInt();
			if(a[i] > a[max]) max = i;
		}
		
		int value = 1;
		
		if(a[max] == 1) value = 2;
		
		a[max] = value;
		
		Arrays.sort(a);
		
		for(int i = 0; i < n; i++) {
			out.print(a[i]);
			out.print(' ');
		}
	}
		
	public static void main(String[] args) {
		new Main().run();
	} 
	
	public void run() {
		try {
			try {
				in = new BufferedReader(new FileReader("INPUT.TXT"));
				out = new PrintWriter(new FileWriter("OUTPUT.TXT"));
			} catch(FileNotFoundException e) {
				in = new BufferedReader(new InputStreamReader((System.in)));
				out = new PrintWriter(System.out);
			}
			
			st = null;
			rnd = new Random();
			
			solve();
			
			out.close();
		} catch(IOException e) {
			e.printStackTrace();
		}	
	}
	
	private String nextToken() throws IOException, NullPointerException {
		while(st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		
		return st.nextToken();
	}
	
	private int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	
	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	
	private double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

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

import java.util.*;
import java.math.*;
public class codeforces {
	 public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] data=new int[n];
		for(int i=0;i<n;i++)
			data[i]=sc.nextInt();
		Arrays.sort(data);
		if(data[n-1]!=1)
			data[n-1]=1;
		else
			data[n-1]=2;
		Arrays.sort(data);
		for(int i=0;i<n;i++)
		{
			System.out.print(data[i]);
			if(i!=n-1)
				System.out.print(" ");
		}
			
		
		return;
	}

}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.util.*;
public class A {
	static int [] reverse = new int [257];
	public static void main (String [] arg) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] A =new int [n];
		for (int i = 0; i<A.length; ++i) A[i] = sc.nextInt();
		Arrays.sort(A);
		if (n == 1) {
			System.out.println( (A[0] == 1) ? "2" : "1");
			return;
		} else if (A[0] == A[A.length-1] && A[0] == 1) {
			System.out.print("1");
			for (int i = 1; i<n-1; ++i) System.out.print(" " + A[i]);
			System.out.println(" 2");
			return;
		} else if (A[0] == A[A.length-1]) {
			System.out.print("1");
			for (int i = 1; i<n; ++i) System.out.print(" " + A[i]);
			System.out.println();
			return;
		} 
		
		for (int i = 0; i<A.length; ++i) {
			int prev = (i == 0) ? Integer.MAX_VALUE : A[i-1];
			int next = (i == A.length-1) ? Integer.MAX_VALUE : A[i+1];
			int ans = Math.min(prev, Math.min(next, A[i]));
			if (i == 0) ans = 1;
			
			System.out.print((i == 0) ? "" + ans : " " + ans);
		}
		System.out.println();
		
		
	}
	
}
// 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 C {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        String[] S = in.readLine().split(" ");
        int[] A = new int[n];
        boolean allOnes = true;
        for (int i = 0; i < n; i++) {
            A[i] = Integer.parseInt(S[i]);
            allOnes &= A[i] == 1;
        }
        Arrays.sort(A);
        if (A[A.length - 1] > 1)
            A[A.length - 1] = 1;
        else
            A[A.length - 1] = 2;
        Arrays.sort(A);
        for (int i = 0; i < A.length; i++)
            System.out.print(A[i] + " ");
        System.out.println();
    }
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class C implements Runnable {

	private void Solution() throws IOException {
		int n = nextInt(), max = 0, maxi = 0;
		ArrayList<Integer> mas = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			int num = nextInt();
			if (num > max) {
				max = num;
				maxi = i;
			}
			mas.add(num);
		}
		mas.remove(maxi);
		mas.add(max == 1 ? 2 : 1);
		Collections.shuffle(mas);
		Collections.sort(mas);
		for (int i = 0; i < n; i++)
			System.out.print(mas.get(i) + " ");
	}

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

	BufferedReader in;
	StringTokenizer tokenizer;

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			Solution();
			in.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

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

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(in.readLine());
		return tokenizer.nextToken();
	}
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.*;
import java.math.*;
import java.util.*;

public class Main
{
    BufferedReader reader;
    FastScanner sc;
    
    void solve() throws Exception
    {
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        if (arr[n - 1] == 1)
            arr[n - 1] = 2;
        else
            arr[n - 1] = 1;
        Arrays.sort(arr);
        for (int i = 0; i < n; i++)
        {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
    }
        
    public static void main(String[] args) throws Exception
    {
        new Main().solve();
    }
    
    Main() throws Exception
    {
        if (System.getProperty("ONLINE_JUDGE") == null)
        {
            //System.setIn(new FileInputStream("input.txt"));
            //System.setOut(new PrintStream("output.txt"));
        }
        
        reader = new BufferedReader(new InputStreamReader(System.in));
        sc = new FastScanner(reader);
    }
}

class FastScanner
{
    BufferedReader reader;
    StringTokenizer strTok;
    
    public FastScanner(BufferedReader reader)
    {
        this.reader = reader;
    }
    
    public String nextToken() throws IOException
    {
        if (strTok == null || !strTok.hasMoreTokens())
        {
            strTok = new StringTokenizer(reader.readLine());
        }
        return strTok.nextToken();
    }
    
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextToken());
    }
    
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextToken());
    }
    
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextToken());
    }
    
    public BigInteger nextBigInteger() throws IOException
    {
        return new BigInteger(nextToken());
    }
    
    public BigDecimal nextBigDecimal() throws IOException
    {
        return new BigDecimal(nextToken());
    }
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class C {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		int n = nextInt();
		int[] mas = new int[n];
		for (int i = 0; i < n; i++) {
			mas[i] = nextInt();
		}

		Arrays.sort(mas);

		if (mas[n - 1] == 1) {
			mas[n - 1] = 2;
		} else {
			mas[n - 1] = 1;
		}
		Arrays.sort(mas);
		for (int i = 0; i < n; i++) {
			System.out.print(mas[i] + " ");
		}

	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.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());
	}

	public static void main(String args[]) throws IOException {
		new C().solution();
	}
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.regex.*;
import static java.lang.Math.*;
public class A {

    public A() throws Exception {
        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i=0;i<n;i++) 
            arr[i] = in.nextInt();

        if (n==1&&arr[0]==1) {
            System.out.println(2); 
            return;
        } 

        Arrays.sort(arr);
        if (arr[n-1]==1)
            arr[n-2] = 2;
        buf.append(1);
        for (int i=0;i<n-1;i++) 
            buf.append(' ').append(arr[i]);
        buf.append('\n');
        System.out.print(buf);
    }

    Scanner in = new Scanner(System.in);
    StringBuilder buf = new StringBuilder();
    public static void main(String[] args) throws Exception { // {{{
        new A();
    } // }}}
    public static void debug(Object... arr) { // {{{
        System.err.println(Arrays.deepToString(arr));
    } // }}}
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.*;
import java.math.*;
import java.util.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
	

	public void solve() throws Exception {
		int n = nextInt();
		int a [] = new int [n];
		for (int i = 0 ;i < n; i++) {
			a[i] = nextInt();
		}
		Arrays.sort(a);
		if (n == 1) {
			if (a[0] == 1) {
				out.print(2);
			} else {
				out.print(1);
			}
		} else {
			out.print(1);
			for (int i = 1; i < n; i++) {
				if (i == n-1 && a[i] == 1) {
					out.print(" "+2);
				} else {
					out.print(" "+a[i-1]);
				}
			}
		}
	}
	
		
	/********************************************************************************************/
	/* THERE IS INPUT */

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	long stime=0;
	
	private String next() throws Exception {
		while (st == null || !st.hasMoreElements())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

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

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

	private double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}
	
	public void run() {
		try {
			//Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			solve();
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} finally {
			out.close();
		}
	}
	
	public static void main(String[] args) throws Exception {
		new Thread(null, new Solution(), "", 1 << 25).start();
	}

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

public class Solution {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        int[] a = new int[n];
        boolean has_more_than_one = false;
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            if (a[i] > 1)
                has_more_than_one = true;
        }

        Arrays.sort(a);

        if (n == 1) {
            if (a[0] == 1)
                out.print(2);
            else
                out.print(1);
        } else {
            out.print(1 + " ");
            for (int i = 1; i < n; i++) {
                if (has_more_than_one || i < n - 1)
                    out.print(a[i - 1] + " ");
                else
                    out.println(2);
            }
        }

        out.close();
    }
}