CodeForces Contest 456 Problem A completed.

Solved in O(nlogn) time.