import java.util.*;


public class Solution {

    public static PriorityQueue<Integer> low = new PriorityQueue<>
    (new Comparator<Integer>() {
        @Override
        public int compare(Integer o1, Integer o2) {
            return o2 - o1;
        }
    });
    public static PriorityQueue<Integer> up = new PriorityQueue<>
    (new Comparator<Integer>() {
        @Override
        public int compare(Integer o1, Integer o2) {
            return o1 - o2;
        }
    });

    static public void Insert(Integer num) {
        int lowSize = low.size();
        if (lowSize == 0) {
            low.add(num);
            return;
        }
        Integer peek = low.peek();
        if (peek < num) {
            up.add(num);
        } else {
            low.add(num);
        }
        lowSize = low.size();
        int upSize = up.size();

        while (lowSize > upSize + 1) {
            Integer poll = low.poll();
            up.add(poll);
            lowSize = low.size();
            upSize = up.size();
        }

        while (upSize > lowSize + 1) {
            Integer poll = up.poll();
            low.add(poll);
            lowSize = low.size();
            upSize = up.size();
        }
    }

    static public Double GetMedian() {
        int lowSize = low.size();
        int upSize = up.size();
        if (lowSize == upSize) {
            return (low.peek() + up.peek()) / 2.00;
        } else if (lowSize > upSize) {
            return low.peek() * 1.00;
        } else {
            return up.peek() * 1.00;
        }
    }


}