Distances are always positive. Find the distance of point A above sea level (sea level is our reference point). Then find the distance of B below sea level (again remembering that distances are always positive). Then sum up the resulting 2 positive numbers to obtain the distance between A and B:
If you go from point A to sea level, you need to go down 5,623 m. If you go from point B to sea level, you need to go up 1,6,868 m245 m. Add the two distances to find the distance between the points.