merge sorted array, carefully deal with border problem.