/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{  Integer[] arr= {10,70,4,15,20,12,8,17};
	   PriorityQueue<Integer>maxheap = new PriorityQueue<>(10, Collections.reverseOrder());
	   PriorityQueue<Integer>minheap = new PriorityQueue<>(10);
	   Integer median = -9999;
	   for (Integer a: arr) {
	   	  if (a >= median) {
             minheap.add(a);
             if (minheap.size() - maxheap.size() >= 2)
                 maxheap.add(minheap.poll());
	   	  }
        	else {
             maxheap.add(a);
             if (maxheap.size() - minheap.size() >= 2)
                 minheap.add(maxheap.poll());
        	} 
    		Integer diff = maxheap.size() - minheap.size();
    		if (diff == 1)
    			 median = maxheap.peek();
        	else if	(diff == -1)
        	   median = minheap.peek();
        	else   
        		median = Math.min(minheap.peek(), maxheap.peek());
    		System.out.println(median);
	   }
	}

}