Double-sided least-squares problem