Optimal estimation of multiple phases