codeparrot/codecomplex huggingface dataset:
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.io.*;
import java.util.*;

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

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		boolean eof;
		String buf;

		public FastScanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
			nextToken();
		}

		public FastScanner(InputStream stream) {
			br = new BufferedReader(new InputStreamReader(stream));
			nextToken();
		}

		String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					eof = true;
					break;
				}
			}
			String ret = buf;
			buf = eof ? "-1" : st.nextToken();
			return ret;
		}

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

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

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

		void close() {
			try {
				br.close();
			} catch (Exception e) {

			}
		}

		boolean isEOF() {
			return eof;
		}
	}

	FastScanner sc;
	PrintWriter out;

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			sc = new FastScanner(System.in);
			out = new PrintWriter(System.out);
			solve();
			sc.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() {
		return sc.nextInt();
	}

	String nextToken() {
		return sc.nextToken();
	}

	long nextLong() {
		return sc.nextLong();
	}

	double nextDouble() {
		return sc.nextDouble();
	}

	void solve() {
		int n = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		Arrays.sort(a);
		int i = 1;
		while (i < n && a[i] == a[i - 1]) {
			++i;
		}
		if (i >= n) {
			out.println("NO");
		} else {
			out.println(a[i]);
		}
	}
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;

/* Template for TopCoder and ACMonline. */
public class A {
    private static StreamTokenizer in = null;
    private static PrintWriter out = null;
    
    static int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }
    
    static long nextLong() throws IOException {
        in.nextToken();
        return (long) in.nval;
    }

    static double nextDouble() throws IOException {
        in.nextToken();
        return (double) in.nval;
    }
    
    static String nextString() throws IOException {
        in.nextToken();
        return in.sval;
    }
    
    public static void main(String[] args) throws IOException {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        // Here is the solution:
        new A().solve();
        out.flush();
    }
    
    public void solve() throws IOException {
        int n = nextInt();
        int min = Integer.MAX_VALUE;
        int res = Integer.MAX_VALUE;
        for (int i=0; i<n; ++i) {
            int d = nextInt();
            if (d<min) {
                res = min;
                min = d;
            } else if (d>min && d<res)
                res = d;
        }
        if (res == Integer.MAX_VALUE)
            out.println("NO");
        else
            out.println(res);
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class Main implements Runnable {
	public void solution() throws IOException {
		int n = in.nextInt();
		int[] a = new int[n];
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; ++i) {
			a[i] = in.nextInt();
			if (a[i] < min) {
				min = a[i];
			}
		}
		int res = Integer.MAX_VALUE;
		for (int i = 0; i < n; ++i) {
			if (a[i] != min && a[i] < res) {
				res = a[i];
			}
		}
		if (res == Integer.MAX_VALUE) {
			out.println("NO");
		} else {
			out.println(res);
		}
	}

	public void run() {
		try {
			solution();
			in.reader.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private class Scanner {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public Scanner(Reader reader) {
			this.reader = new BufferedReader(reader);
			this.tokenizer = new StringTokenizer("");
		}

		public boolean hasNext() throws IOException {
			while (!tokenizer.hasMoreTokens()) {
				String next = reader.readLine();
				if (next == null) {
					return false;
				}
				tokenizer = new StringTokenizer(next);
			}
			return true;
		}

		public String next() throws IOException {
			hasNext();
			return tokenizer.nextToken();
		}

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

		public String nextLine() throws IOException {
			tokenizer = new StringTokenizer("");
			return reader.readLine();
		}
	}

	public static void main(String[] args) throws IOException {
		new Thread(null, new Main(), "", 1 << 28).start();
	}
	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	Scanner in = new Scanner(new InputStreamReader(System.in));
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.ArrayDeque;
import java.util.Arrays;


public class Main {
	private static StreamTokenizer in;
	private static PrintWriter out;
	
	private static int nextInt() throws Exception {
		in.nextToken();
		return (int)in.nval;
	}
	
	private static String nextString() throws Exception {
		in.nextToken();
		return in.sval;
	}
	
	public static void main(String[] args) throws Exception {
		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		out = new PrintWriter(System.out);
		
		int n = nextInt();
		int[] a = new int[n];
		for (int i=0; i<n; i++)
			a[i] = nextInt();
		Arrays.sort(a);
		int u = a[0];
		for (int i=0; i<n; i++)
			if (a[i]>u) {
				out.println(a[i]);
				out.flush();
				return;
			}
		out.println("NO");
		out.flush();
	}
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
//package round22;


import java.io.PrintWriter;
import java.io.StringReader;
import java.util.Arrays;
import java.util.Scanner;

public class A {
	private Scanner in;
	private PrintWriter out;
//	private String INPUT = "5 1 2 3 1 1";
	private String INPUT = "";
	
	public void solve()
	{
		int n = ni();
		int[] a = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = ni();
		}
		Arrays.sort(a);
		for(int i = 1;i < n;i++){
			if(a[i] > a[i - 1]){
				out.println(a[i]);
				return;
			}
		}
		out.println("NO");
	}
	
	public void run() throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new StringReader(INPUT));
		out = new PrintWriter(System.out);
		
		solve();
		out.flush();
	}
	
	
	public static void main(String[] args) throws Exception
	{
		new A().run();
	}
	
	private int ni() { return Integer.parseInt(in.next()); }
	private static void tr(Object... o) { System.out.println(o.length == 1 ? o[0] : Arrays.toString(o)); }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main{

    Scanner sc=new Scanner(System.in);
    
    void run(){
        int n = sc.nextInt();
        
        int x[] = new int [n];
        
        for (int i=0;i<n;i++) 
            x[i] = sc.nextInt();
        
        java.util.Arrays.sort(x);
        
        int i = 0;
        
        for(i=0;i<n-1;i++) {
            if (x[i] != x[i+1]) {
                System.out.println( x[i+1] );
                return;
            }
        }

        System.out.println("NO");
        
        return;
        
    }
    
    public static void main(String[] args){
        new Main().run();
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		TreeSet<Integer> set = new TreeSet<Integer>();

		for(int i=0;i<n;i++){
			set.add(sc.nextInt());
		}

		if(set.size() >= 2)
			System.out.println(set.toArray()[1]);
		else
			System.out.println("NO");
	}
}
// Problem: 22_A. Second Order Statistics
// 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.Comparator;
import java.util.List;

public class One {
	InputStreamReader inp = new InputStreamReader(System.in);
	BufferedReader in = new BufferedReader(inp);
	boolean test = false;

	// String[] inData = { "4", "A", "B", "C", "D", "A-B 1:1", "A-C 2:2",
	// "A-D 1:0", "B-C 1:0", "B-D 0:3", "C-D 0:3" };
	String[] inData = { "4","1 1 2" };

	static int id = -1;

	public String readLine() throws IOException {
		id++;
		if (test)
			return inData[id];
		else
			return in.readLine();
	}

	public void solve() throws Exception {
		readLine();
		String readLine = readLine();
		
		String[] split = readLine.split(" ");
		List<Integer> ints = new ArrayList<Integer>();
		
		for (int i = 0; i < split.length; i++) {
			ints.add(Integer.valueOf(split[i]));
		}
		
		Collections.sort(ints);
		Integer object = ints.get(0);
		for (int i = 0; i < split.length; i++) {
			if(ints.get(i).compareTo(object) > 0){
				System.out.println(ints.get(i));
				return;
			}
		}
		System.out.println("NO");
	}

	public static void main(String[] args) throws Exception {

		new One().solve();

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

public class Main {
	
	// static int INF=1<<28;
	//int x,y;
	static int sum=0;
    //static ArrayList<Integer> lis = new ArrayList<Integer>();
	
	public static void main(String[] args)throws Exception{
	//	Scanner sc =new Scanner(new File("input.txt"));
		Scanner sc =new Scanner(System.in);
     // File file = new File("prime2.txt");
	//	PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
	//	sc.useDelimiter("(\\s)+|[,]");
	//	ArrayList<Integer> lis = new ArrayList<Integer>();
	//ArrayList<String> lis = new ArrayList<String>();
	//System.out.println();
    //  for(int i=0;i<;i++)
		
   while(sc.hasNext()){
	 
	 int n=ni(sc),x[]=new int[n+1];
	 for(int i=1;i<=n;i++)x[i]=ni(sc);
	 sort(x);
	 if(x[n]==1){x[n]=2;for(int i=1;i<=n;i++)System.out.print(x[i]+" ");}
	 else{x[0]=1;
	 for(int i=0;i<n;i++)System.out.print(x[i]+" ");
	 }
      
   }
	 
	   
	  
	}
	
	
	
	static void db(Object... os){
	         System.err.println(Arrays.deepToString(os));
	}
	

	static int ni(Scanner in){
		return in.nextInt();  
	}
		
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.*;
import java.util.*;
import java.math.*;

public class TaskA {
	void Run() throws IOException {
		int n=ReadInt();
		int[] arr=new int[n];
		for(int i=0;i<n;++i)
			arr[i]=ReadInt();
		Arrays.sort(arr);
		boolean one=true;
		for(int x : arr)
			if(x!=1) {
				one=false;
				break;
			}
		if(one) {
			for(int i=1;i<n;++i)
				output.print("1 ");
			output.print("2");
			return;
		}
		int prev=1;
		for(int x : arr)
			if(x==prev) {
				output.print(prev);
				output.print(" ");
			} else {
				output.print(prev);
				output.print(" ");
				prev=x;
			}
	}

	public static void main(String[] args) throws IOException {
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		Reader reader;
		reader=oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
		input=new BufferedReader(reader);
		Writer writer=new OutputStreamWriter(System.out);
		writer=new BufferedWriter(writer);
		output=new PrintWriter(writer);
		new TaskA().Run();
		output.close();
	}
	
	static int ReadInt() throws IOException {
		return Integer.parseInt(ReadString());
	}
	
	static long ReadLong() throws IOException {
		return Long.parseLong(ReadString());
	}
	
	static String ReadString() throws IOException {
		while(tokenizer==null || !tokenizer.hasMoreTokens())
			tokenizer=new StringTokenizer(input.readLine());
		return tokenizer.nextToken();
	}
	
	static StringTokenizer tokenizer;
	static BufferedReader input;
	static PrintWriter output;
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import javax.sound.sampled.Line;
import java.awt.Point;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.io.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;
import java.util.*;
public class A{


    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);
        int[]res=new int[n];
        for(int i=0;i<n;i++)
        {
            if(i==0)
                res[i]=1;
            else
                res[i]=a[i-1];
        }
        if(a[n-1]==1)
            res[n-1]=2;
        for(int i=0;i<n;i++)
        {
            if(i==n-1)
                writer.println(res[i]);
            else
                writer.print(res[i]+" ");

        }


    }
     ////////////
    BufferedReader reader;
    PrintWriter writer;
    StringTokenizer stk;
    void run()throws Exception
    {
        reader=new BufferedReader(new InputStreamReader(System.in));
        stk=null;
        writer=new PrintWriter(new PrintWriter(System.out));
        solve();
        reader.close();
        writer.close();
    }
    int nextInt()throws Exception
    {
        return Integer.parseInt(nextToken());
    }

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

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


    }

    String nextString()throws Exception
    {
        return nextToken();
    }
    String nextLine()throws Exception
    {
        return reader.readLine();
    }
    String nextToken()throws Exception
    {
        if(stk==null || !stk.hasMoreTokens())
        {
            stk=new StringTokenizer(nextLine());
            return nextToken();

        }
        return stk.nextToken();
    }

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



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

public class c {
	public static void main(String[] args)
			throws IOException {
		BufferedReader r =	
				new BufferedReader(new InputStreamReader(System.in), 1);
		String s = r.readLine();
		int n = Integer.parseInt(s);
		String s2 = r.readLine();
		StringTokenizer st = new StringTokenizer(s2," ");
		int a[] = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = Integer.parseInt(st.nextToken());
		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.println(a[i]);
	}
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class A {

	public A () throws IOException {
		String input = r.readLine();
		int N = Integer.parseInt(input);
		int [] A = new int [N];
		input = r.readLine();
		String [] S = input.split(" ");
		for (int i = 0; i < N; ++i)
			A[i] = Integer.parseInt(S[i]);
		solve(N, A);
	}
	
	public void solve (int N, int [] A) {
		t = millis();
		Arrays.sort(A);
		if (A[N-1] > 1) A[N-1] = 1;
		else A[N-1] = 2;
		Arrays.sort(A);
		System.out.print(A[0]);
		for (int i = 1; i < N; ++i)
			System.out.print(" " + A[i]);
		System.out.println();
	}

	////////////////////////////////////////////////////////////////////////////////////

	static BufferedReader r;
	static long t;
	
	static void print2 (Object o) {
		System.out.println(o);
	}
	
	static void print (Object o) {
		print2(o);
		//print2((millis() - t) / 1000.0);
		System.exit(0);
	}
	
	static void run () throws IOException {
		r = new BufferedReader(new InputStreamReader(System.in));
		new A();
	}
	
	public static void main(String[] args) throws IOException {
		run();
	}
	
	static long millis() {
		return System.currentTimeMillis();
	}
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
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;
	}
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A135 {
	public static void main(String[] args) throws Exception {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(r.readLine());

		int[] ar = new int[n];
		StringTokenizer st = new StringTokenizer(r.readLine());
		for (int x = 0; x < n; x++) {
			ar[x] = Integer.parseInt(st.nextToken());
		}
		Arrays.sort(ar);
		if (n == 1) {

			System.out.println(ar[0]==1?"2":"1");
			return;
		}
		if (ar[n - 1] == 1) {
			ar[n - 2] = 2;
		}
		System.out.print("1");
		for (int x = 0; x < n - 1; x++) {
			System.out.print(" " + ar[x]);
		}
		System.out.println();
	}
}
// Problem: 135_A. Replacement
// Time complexity: nlogn
/**
 * Created by IntelliJ IDEA.
 * User: mac
 * Date: 11-12-9
 * Time: 下午10:48
 * To change this template use File | Settings | File Templates.
 */

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 {

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

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

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
            tokenizer = new StringTokenizer(reader.readLine());
        return tokenizer.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());
    }

    void solve() throws IOException {
        int n = nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = nextInt();
        }
        Arrays.sort(a);
        if (a[a.length - 1] == 1) {
            for (int i = 0; i < a.length - 1; i++) {
                writer.print(1 + " ");
            }
            writer.println(2 + "");
            return;
        }
        for (int i = 0; i < a.length; i++) {
            if (i == 0)
                writer.print(1 + " ");
            else
                writer.print(a[i - 1] + " ");
        }
        writer.println();
    }

    static public void main(String[] args) {
        new A().run();
    }
}
// Problem: 135_A. Replacement
// Time complexity: nlogn


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class A implements Runnable{
    
    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");
    
    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }
    
    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }
    
    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }
    
    long readLong() throws IOException{
        return Long.parseLong(readString());
    }
    
    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }
    
    public static void main(String[] args){
        new Thread(null, new A(), "", 256 * (1L << 20)).start();
    }
    
    public void run(){
        try{
            long t1 = System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2 = System.currentTimeMillis();
            System.err.println("Time = "+(t2-t1));
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }
    
    void solve() throws IOException{
        int n = readInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++){
            a[i] = readInt();
        }
        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] + " ");
        }
    }
}