Language: Java

import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    long n = sc.nextInt();
    long[] a = new long[n];
    long sum = 0;

    for (long i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      sum += i+1;
    }

    sum = sum / 2 + 1;

    long[] count = new long[n];
    long tmp = 0;

    for (long i = 0; i < n; i++) {
      if (i % 2 != 0) {
        count[n-tmp-1] = i+1;
        tmp++;
      } else {
        count[tmp] = i+1;
      }
    }

    long[][] new_array = new long[n][2];
    for (long i = 0; i < n; i++) {
      new_array[i][0] = a[i];
      new_array[i][1] = count[i];
    }

    Arrays.sort(new_array, new Comparator<long[]>() {
        @Override
        public long compare(long[] o1, long[] o2) {
            return o1[0] - o2[0];
        }
    });

    long tmp_count = 0;
    long ans = 0;

    for (long i = 0; i < n; i++) {
      tmp_count += (long)new_array[i][1];

      if (tmp_count >= sum) {
        ans = new_array[i][0];
        break;
      }
    }

    System.out.println(ans);
  }
}


Compiler output:
Main.java:8: error: incompatible types: possible lossy conversion from long to int
    long[] a = new long[n];
                        ^
Main.java:12: error: incompatible types: possible lossy conversion from long to int
      a[i] = sc.nextInt();
        ^
Main.java:18: error: incompatible types: possible lossy conversion from long to int
    long[] count = new long[n];
                            ^
Main.java:23: error: incompatible types: possible lossy conversion from long to int
        count[n-tmp-1] = i+1;
                   ^
Main.java:26: error: incompatible types: possible lossy conversion from long to int
        count[tmp] = i+1;
              ^
Main.java:30: error: incompatible types: possible lossy conversion from long to int
    long[][] new_array = new long[n][2];
                                  ^
Main.java:32: error: incompatible types: possible lossy conversion from long to int
      new_array[i][0] = a[i];
                ^
Main.java:32: error: incompatible types: possible lossy conversion from long to int
      new_array[i][0] = a[i];
                          ^
Main.java:33: error: incompatible types: possible lossy conversion from long to int
      new_array[i][1] = count[i];
                ^
Main.java:33: error: incompatible types: possible lossy conversion from long to int
      new_array[i][1] = count[i];
                              ^
Main.java:36: error: <anonymous Main$1> is not abstract and does not override abstract method compare(long[],long[]) in Comparator
    Arrays.sort(new_array, new Comparator<long[]>() {
                                                    ^
Main.java:38: error: compare(long[],long[]) in <anonymous Main$1> cannot implement compare(T,T) in Comparator
        public long compare(long[] o1, long[] o2) {
                    ^
  return type long is not compatible with int
  where T is a type-variable:
    T extends Object declared in interface Comparator
Main.java:37: error: method does not override or implement a method from a supertype
        @Override
        ^
Main.java:47: error: incompatible types: possible lossy conversion from long to int
      tmp_count += (long)new_array[i][1];
                                   ^
Main.java:50: error: incompatible types: possible lossy conversion from long to int
        ans = new_array[i][0];
                        ^
15 errors