Given an array of size n containing integers and a sum initialized to 0. Print the sum after n1 operations, i.e. when only 1 element is left. e.g. How do I approach this problem in efficient manner? I am not able to understand the approach in editorial asked 21 Sep '16, 21:54

You can just use segment tree (or sets) to solve this question. Keep 2 sets :
Now every time when you extract the minimum from the first set, delete that from the first set and on the second set, use lower_bound to find it's current neighbors. After that, just delete the extracted position of the minimum element from the second set. No need for a treap, or rather an implicit treap :P answered 22 Sep '16, 13:59

You could use an implicit treap to solve the problem in $O(n \log n)$, although that's probably overkill :P