import java.util.*; public class Solution { static class Median { final PriorityQueue lower, higher; int count; Median() { lower = new PriorityQueue<>(11, Comparator.reverseOrder()); higher = new PriorityQueue<>(11); // Avoid NPE in push() lower.add(Integer.MIN_VALUE); higher.add(Integer.MAX_VALUE); count = 2; } Median(int capacity) { lower = new PriorityQueue<>(capacity/2+2, Comparator.reverseOrder()); higher = new PriorityQueue<>(capacity/2+2); // Avoid NPE in push() lower.add(Integer.MIN_VALUE); higher.add(Integer.MAX_VALUE); count = 2; } void push(int a) { if (count % 2 == 0) { lower.add(a); } else { higher.add(a); } if (lower.peek() > higher.peek()) { Integer high = lower.poll(); Integer low = higher.poll(); higher.add(high); lower.add(low); } count++; } Integer get() { return lower.peek(); } void erase(int a) { if (lower.remove(a)) { if (lower.size() < higher.size()) { lower.add(higher.poll()); } } else if (higher.remove(a)) { if (lower.size() + 1 > higher.size()) { higher.add(lower.poll()); } } count--; } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); final int h = 400; List a = new ArrayList<>(); for(int i=0; i v1 = new ArrayList<>(); List v2 = new ArrayList<>(); v1.add(0L); v2.add(0L); long no1 = 0; long no2 = 0; long ma1 = 0; long ma2 = 0; for(int i=0; i+k<=n; i+=k) { Median med1 = new Median(k); Median med2 = new Median(k); for(int j=i; j vm1 = new ArrayList<>(); List vm2 = new ArrayList<>(); for(int i=0; i v1 = new ArrayList<>(); List v2 = new ArrayList<>(); v1.add(0L); v2.add(0L); long no1 = 0; long no2 = 0; long ma1 = 0; long ma2 = 0; for(int i=0; i n) { vm1.remove(vm1.size()-1); vm2.remove(vm2.size()-1); continue; } for(int j=bleft; j