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

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

    public void solve() throws Exception {
        n = nextInt();
        int a[]= new int[n], pos = 1;
        for(int i=0; i<n; i++)
            a[i] = nextInt();
        Arrays.sort(a);
        if(n == 1){
            out.println("NO"); return;
        }
        boolean has = false;
        for(; pos<n; pos++){
            if(a[pos] != a[0]){
                has = true;
                break;
            }
        }
        if(!has){
            out.println("NO");
        }
        else{
            out.println(a[pos]);
        }
    }
    public int n, m;

    public void run() throws Exception {
        inter = new StreamTokenizer(new BufferedReader(new InputStreamReader(
                System.in)));
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        solve();
        out.flush();
    }
    public BufferedReader in;
    public StreamTokenizer inter;
    public PrintWriter out;

    public int nextInt() throws Exception {
        inter.nextToken();
        return (int) inter.nval;
    }
    public String nextLine() throws Exception{
        return in.readLine();
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*;

public class A {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int first = Integer.MAX_VALUE, second = Integer.MAX_VALUE;

        for (int i = 0, x; i < N; ++i) {
            x = sc.nextInt();
            if (x < first) {
                second = first;
                first = x;
            } else if (x > first && x < second) {
                second = x;
            }
        }

        if (second == Integer.MAX_VALUE)
            System.out.println("NO");
        else
            System.out.println(second);
    }

}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;

public class A {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<Integer> set = new HashSet<Integer>();
        
        for ( int i = 0 ; i < n ; ++i ) {
            set.add(sc.nextInt());
        } // for i
        
        ArrayList<Integer> list = new ArrayList<Integer>(set);
        Collections.sort(list);
        if(list.size() > 1)
        System.out.println(list.get(1));
        else
            System.out.println("NO");
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn


import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class A {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new InputStreamReader(System.in));
		int n = s.nextInt();	
		int [] ar = new int[n];
		for (int i = 0; i < n ; i++) {
			ar[i] = s.nextInt();
	 	}
		if(ar.length == 1){
			System.out.println("NO");
		}else{
			Arrays.sort(ar);
			int num = ar[0];
			boolean flag = false;
			for (int i = 1; i < ar.length; i++) {
				if(ar[i]!= num){
					System.out.println(ar[i]);
					flag = true;
					break;
				}
			}
			if(!flag)
				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.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine());
		
		int nums[] = new int[n];
		StringTokenizer tokenizer = new StringTokenizer(in.readLine(), " ");

		for (int i = 0; i < n; i++) {
			nums[i] = Integer.parseInt(tokenizer.nextToken());
		}
		
		Arrays.sort(nums);
		int min = nums[0];
		int so = -200;
		for (int i = 1; i < n; i++) {
			if(nums[i] != min) {
				so = nums[i];
				break;
			}
		}
		if(so != -200)
		System.out.println(so);
		else
			System.out.println("NO");
	}
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class Main implements Runnable {

	public void _main() 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 i = 1; i < n; i++)
			if (a[i] != a[0]) {
				out.print(a[i]);
				return;
			}
		out.print("NO");
	}

	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;

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

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

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

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

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

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			_main();

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

}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import static java.util.Arrays.sort;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.SortedSet;
import java.util.StringTokenizer;
import java.util.TreeSet;

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

  private void solve() throws Exception
  {
    int n = nextInt();
    SortedSet<Integer> sset = new TreeSet<Integer>();
    for (int i = 0; i < n; i++)
    {
      int a = nextInt();
      sset.add(a);
    }

    if (sset.size() < 2)
      out.println("NO");
    else
    {
      Integer v[] = (Integer[]) sset.toArray(new Integer[sset.size()]);
      sort(v);
      out.println(v[1]);
    }
  }

  // -------------- Input/Output routines below ---------------//
  private BufferedReader in;
  PrintWriter out;
  StringTokenizer tokenizer;

  public void run()
  {
    // String problem = this.getClass().getName();
    try
    {
      in = new BufferedReader(new InputStreamReader(System.in));
      out = new PrintWriter(new BufferedOutputStream(System.out));
      solve();
      out.flush();
      in.close();
      out.close();
    }
    catch (Exception e)
    {
      e.printStackTrace();
      // System.exit(1);
    }
  }

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

}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Date;
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	    Scanner s = new Scanner(System.in);
	    int n = s.nextInt();
	    int[] a = new int[n];
	    for(int i=0;i<n;i++)
	        a[i] = s.nextInt();
	    Arrays.sort(a);
	    int min = a[0];
	    if (a[0] == a[n-1]){
	        System.out.println("NO");
	    }else{
	        for(int i=1;;i++){
	            if (a[i] > min) {
	                System.out.println(a[i]);
	                break;
	            }
	        }
	    }
	}

}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Solution {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st;

    void solve() throws IOException {
        int n = ni();
        int[] v = new int[n];
        for (int i = 0; i < n; ++i)
            v[i] = ni();
        Arrays.sort(v);
        int mn = v[0];
        for (int i = 1; i < n; ++i)
            if (v[i] > mn) {
                out.println(v[i]);
                return;
            }
        out.println("NO");
    }

    public Solution() throws IOException {
        Locale.setDefault(Locale.US);
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

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

    int ni() throws IOException {
        return Integer.valueOf(ns());
    }

    long nl() throws IOException {
        return Long.valueOf(ns());
    }

    double nd() throws IOException {
        return Double.valueOf(ns());
    }

    public static void main(String[] args) throws IOException {
        new Solution();
    }
}
// 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;

public class A22 {

	static StreamTokenizer in;
	static PrintWriter out;
	
	static int nextInt() throws IOException {
		in.nextToken();
		return (int)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);

		int n = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		
		Arrays.sort(a);
		int f = a[0], q = 1;
		while (q < n && a[q] == f) q++;
		
		out.println(q < n ? a[q] : "NO");
		
		out.flush();
	}

}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn


/**
 *
 * @author ishani
 */
import java.util.*;
public class A {

    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++){
            int a = sc.nextInt();
            set.add(a);
        }

        if(set.size()==1)System.out.println("NO");
        else{
            set.remove(set.first());
            System.out.println(set.first());
        }
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;


public class CF22_1 {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int num=sc.nextInt();
    if(num!=1)
    {
        ArrayList<Integer>data=new ArrayList<Integer>();
        for (int i=0;i<num;i++){
            data.add(sc.nextInt());
            
        }
        Collections.sort(data);
        
        int ind=1;
    
        while( data.get(ind-1)==data.get(ind) )
            {
            ind++;
            if(ind ==data.size())
                break;
            }
        
        if(data.size()>ind)
        System.out.println(data.get(ind));
        else
            System.out.println("NO");
        
        
    }
    else
        System.out.println("NO");
    }
    
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*; 
 
public class Main 
{ 
 public static void main(String[] args) 
 { 
  Scanner keyboard = new Scanner(System.in); 
  int size = keyboard.nextInt(); 
  int[] arr = new int[size]; 
  int i = 0; 
  while( size != 0 ) 
  {  
   arr[i] = keyboard.nextInt(); 
   size--;  
   i++; 
  } 
   //System.out.print("size " + arr.length );
   Arrays.sort(arr); 
 
   int index = 0; 
   boolean val = false; 
   int ans = 0; 
   for ( i = 0; i< arr.length-1 ; i++ ) 
   { 
    //System.out.print(" arr[i] " + arr[i] + " arr[i+1] " + arr[i+1] + "\n" );
    if( arr[i] != arr[i+1] ) 
    { 
     val = true; 
     //System.out.print("Changed val to true");
     index = i+1; 
      System.out.println(arr[index]); 
      return; 
    } 
   } 
     
    if (size == 1 || ( val == false))
    { 
        System.out.println("NO");    
    } 
 
    
 } 
  
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class A {

    void run()throws IOException{
        Scanner sc = new Scanner(new InputStreamReader(System.in));
        int n = sc.nextInt();
        int i;
        int[] ar = new int[n];
        for(i=0; i<n; i++){
            ar[i] = sc.nextInt();
        }
        Arrays.sort(ar);
        int min = ar[0];
        for(i=1;i<n;i++){
            if(ar[i]>min) break;
        }
        if(i<n) System.out.println(ar[i]);
        else System.out.println("NO");
    }
    
    public static void main(String[] args)throws IOException {
        new A().run();
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*;

public class Beta22PA {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int minimum = 200, second = 200;
		for(int i=0; i<n; i++) {
			int temp = scan.nextInt();
			if(temp<minimum) {
				second = minimum;
				minimum = temp;
			} else if(temp>minimum&&temp<second) {
				second = temp;
			}
		}
		if(second>100) {
			System.out.println("NO");
		} else {
			System.out.println(second);
		}
	}
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class order {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(new BufferedWriter(
				new OutputStreamWriter(System.out)));
		int n=Integer.parseInt(in.readLine());
		Set<Integer> set = new TreeSet<Integer>();
		StringTokenizer st= new StringTokenizer(in.readLine());
		int a;
		List<Integer> list =new LinkedList<Integer>();
		while(st.hasMoreTokens()){
			a= Integer.parseInt(st.nextToken());
			if(!set.contains(a)){
				list.add(a);
				set.add(a);
			}
			
		}
		if(list.size()==1){
			out.println("NO");
		}else{
			Collections.sort(list);
			out.println(list.get(1));
		}
		out.close();
		System.exit(0);
	}
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*;
import java.math.*;
/**
 *
 * @author Izhari Ishak Aksa
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Hashtable<Integer, Integer> hi = new Hashtable<Integer, Integer>();
        for (int i = 0; i < n; i++) {
            int m = sc.nextInt();
            hi.put(m, 1);
        }
        Set<Integer> set = hi.keySet();
        Integer[] key = set.toArray(new Integer[set.size()]);
        Arrays.sort(key);
        try {
            System.out.println(key[1]);
        } catch (Exception e) {
            System.out.println("NO");
        }
    }

}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.StreamTokenizer;
import java.lang.reflect.Array;
import java.util.Arrays;


public class a {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		//BufferedReader input = new BufferedReader(new FileReader("input.txt"));
		//BufferedWriter output = new BufferedWriter(new FileWriter("output.txt"));
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
		StreamTokenizer in = new StreamTokenizer(input);
		
		in.nextToken();
		int n = (int)in.nval;
		int[] mas = new int[n];
		
		for (int i = 0; i < n; i++) {
			in.nextToken();
			mas[i] = (int)in.nval;
		}
		
		Arrays.sort(mas);
		int min = mas[0];
		int i = 1;
		
		while ((i < n)&&(min == mas[i])) {
			i++;
		}
		
		if (i < n) {
			output.write(Integer.toString(mas[i]));
		}
		else {
			output.write("NO");
		}
		input.close();
		output.close();
	}

}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*;
public class Test 
{
    public static void main(String[] args) 
    {
    	Scanner t = new Scanner(System.in);
    	int n=t.nextInt();
    	int a[]= new int[n];
    	for(int i=0; i<n; i++)
    		a[i]=t.nextInt();
    	Arrays.sort(a);
    	int r=a[0];
    	for(int i=1; i<n; i++)
    			if(a[i]!=r)
    			{
    				System.out.println(a[i]);
    				System.exit(0);
    			}
    	System.out.println("NO");       	
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
//package a_vtoray_poriadkovay_statistika;

import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author kal1sha
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic hereSc
        int n, i;
        boolean status = false;
        int answer;
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        int a[] = new int[n];
        for (i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        answer = a[0];
        for (i = 1; i < n; i++) {
            if (a[i] != answer) {
                answer = a[i];
                status = true;
                i = n + 1;
            }
        }
        if (status) {
            System.out.println(answer);
        } else {
            System.out.println("NO");
        }
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;


public class A {

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

	private void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		Arrays.sort(a);
		int i = 0;
		while (i < n && a[i] == a[0])
			i++;
		if (i < n)
			System.out.println(a[i]);
		else
			System.out.println("NO");
		sc.close();
	}


}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*;
import java.io.*;
public class Main {
    public static void main (String [] args) throws IOException {
        BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int [] nums = new int[n];
        args = br.readLine().split(" ");
        for (int i = 0; i < n; i++) {
            nums[i] = Integer.parseInt(args[i]);
        }
        Arrays.sort(nums);
        int min = nums[0];
        for (int i = 1; i < n; i++) {
            if (nums[i]>min) {
                System.out.println(nums[i]); return;
            }
        }
        System.out.println("NO");
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*;

public class CDF22_A {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i=0; i<N; i++)
            A[i] = sc.nextInt();
        Arrays.sort(A);
        int i = 0;
        while (i < A.length && A[i] == A[0]) i++;
        System.out.println(i == A.length ? "NO" : A[i]);
        sc.close();
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*;
import java.io.*;

public class A {

    public static void main(String[] args) {
        Scanner s = new Scanner(new InputStreamReader(System.in));
        int n = s.nextInt();
        if (n == 1) {
            System.out.println("NO");
            System.exit(0);
        }
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = s.nextInt();
        }
        Arrays.sort(nums);
        int x = 1;
        while (x < n && nums[x] == nums[x - 1])
            x++;
        if (x == n) {
            System.out.println("NO");
            System.exit(0);
        } else {
            System.out.println(nums[x]);
            System.exit(0);
        }

    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {
        //System.setIn(new FileInputStream("1"));
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        solve();

        in.close();
        out.close();
    }

    private static void solve() throws Exception {
        int n = nextInt();
        boolean[] use = new boolean[500];
        ArrayList<Integer> a = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            int v = nextInt();
            if (!use[250 + v]) {
                use[250 + v] = true;
                a.add(v);
            }
        }
        Collections.sort(a);
        if (a.size() < 2) {
            out.println("NO");
        } else {
            out.println(a.get(1));
        }
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer st;

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

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

    static double nextDouble() throws IOException {
        return Double.parseDouble(nextString());
    }
}
// Problem: 22_A. Second Order Statistics
// Time complexity: nlogn
import java.util.*;   
   
public class Main   
{   
 public static void main(String[] args)   
 {   
  Scanner keyboard = new Scanner(System.in);   
  int size = Integer.parseInt(keyboard.nextLine());   
  int[] arr = new int[size];   
  int i = 0;   
  while( size != 0 )   
  {    
   arr[i] = keyboard.nextInt();   
   size--;    
   i++;   
  }   
   
  if( arr.length == 1 )    
  {   
   System.out.println("NO");   
  }   
  else   
  {   
   Arrays.sort(arr);   
   boolean val = false;   
   int ans = 0;   
   for ( i = 0; i< arr.length-1 ; i++ )   
   {   
    if( arr[i] != arr[i+1] )   
    {   
     val = true;   
     ans = arr[i+1];   
     System.out.println(ans);   
     i = arr.length;   
    }    
    else if( i == arr.length-2 ) //val == false  
    {   
     System.out.println("NO");      
    }   
   }   
  }
 }
}