A Near-optimal Algorithm for Finding the Median Distributively