nlogn works