import java.util.*;
public class Solution {
    private int N = 0;
    private PriorityQueue<Integer> left = new PriorityQueue<>(new Comparator<Integer>() {
        public int compare(Integer i1, Integer i2) {
            return i2 - i1;
        }
    });
    private PriorityQueue<Integer> right = new PriorityQueue<>();
    public void Insert(Integer num) {
        if((N & 1) == 0) {
            right.offer(num);
            left.offer(right.poll());
        } else {
            left.offer(num);
            right.offer(left.poll());
        }
        N++;
    }
    public Double GetMedian() {
        if((N & 1) == 0) {
            return (left.peek() + right.peek()) / 2.0;
        } else {
            return (double)left.peek();
        }
    }
}