package no318; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map; import java.util.NoSuchElementException; public class Main { public static void main(String[] args) { IO io = new IO(); int n = io.nextInt(); HashMap hm = new HashMap<>(); for(int i=0;i> al = new ArrayList<>(hm.entrySet()); al.sort((x,y) -> Integer.compare(x.getKey(), y.getKey())); RangeSetRangeSumLong st = new RangeSetRangeSumLong(n); // System.out.println(al); for(Map.Entry entry:al) { Interval v = entry.getValue(); st.set(v.first, v.last + 1, entry.getKey()); } long[] ans = st.data(); for(int i=0;i 0) { io.print(" "); } io.print(ans[i]); } io.println(); io.flush(); } } class Interval { int first,last; public Interval(int x) { first = last = x; } public void add(int x) { first = Math.min(first, x); last = Math.max(last, x); } public String toString() { return "[" + first + "," + last + "]"; } } class RangeSetRangeSumLong { private int size,n; private long[] sum; private boolean[] lazy; private long[] lazyValue; public RangeSetRangeSumLong(int size) { this.size = size; n = 1; while(n> 1; lazy[k*2+1] = lazy[k*2+2] = true; lazyValue[k*2+1] = lazyValue[k*2+1] = lazyValue[k]; } lazy[k] = false; } public void set(int begin,int end,long x) { set(begin,end,x,0,0,n); } private void set(int begin,int end,long x,int k,int l,int r) { propagate(k); if (r <= begin || end <= l) { return; } if (begin <= l && r <= end) { sum[k] = x * (r - l); lazy[k] = true; lazyValue[k] = x; propagate(k); return; } set(begin,end,x,k*2+1,l,(l+r)>>>1); set(begin,end,x,k*2+2,(l+r)>>>1,r); sum[k] = sum[k*2+1] + sum[k*2+2]; } public long sum(int begin,int end) { return sum(begin,end,0,0,n); } private long sum(int begin,int end,int k,int l,int r) { propagate(k); if (r <= begin || end <= l) { return 0; } if (begin <= l && r <= end) { return sum[k]; } long sum1 = sum(begin,end,k*2+1,l,(l+r)/2); long sum2 = sum(begin,end,k*2+2,(l+r)/2,r); sum[k] = sum[k*2+1] + sum[k*2+2]; return sum1 + sum2; } public long[] data() { for(int i=0;i data = new ArrayList<>(); for(int i=0;i Integer.MAX_VALUE) { throw new NumberFormatException(); } return (int) nl; } public char nextChar() { if (!hasNext()) { throw new NoSuchElementException(); } return (char) readByte(); } public double nextDouble() { return Double.parseDouble(next());} public int[] nextIntArray(int n) { int[] a = new int[n]; for(int i=0;i