length of longest ascending sequence, O(nlogn)