if partialSum is invalid, use the max partialSum possible to minimize memory usage