refined merge sorted array problem