Albatrosses can travel a thousand kilometres daily over the oceans. They extract their propulsive energy from horizontal wind shears with a flight strategy called dynamic soaring. While thermal soaring, exploited by birds of prey and sports gliders, consists of simply remaining in updrafts, extracting energy from horizontal winds necessitates redistributing momentum across the wind shear layer, by means of an intricate and dynamic flight manoeuvre. Dynamic soaring has been described as a sequence of half-turns connecting upwind climbs and downwind dives through the surface shear layer. Here, we investigate the optimal (minimum-wind) flight trajectory, with a combined numerical and analytic methodology. We show that contrary to current thinking, but consistent with GPS recordings of albatrosses, when the shear layer is thin the optimal trajectory is composed of small-angle, large-radius arcs. Essentially, the albatross is a flying sailboat, sequentially acting as sail and keel, and is most efficient when remaining crosswind at all times. Our analysis constitutes a general framework for dynamic soaring and more broadly energy extraction in complex winds. It is geared to improve the characterization of pelagic birds flight dynamics and habitat, and could enable the development of a robotic albatross that could travel with a virtually infinite range.