median of unsorted array