Prediction of the stability of the Mn+1AXn phases from first principles