added maxSpan, canBalance, maxScalarSum