A mean identity for longest increasing subsequence problems