Longest increasing subsequence of a sequence (Bridge on spoj).