optimized code for boundary checking when adding mineSum
optimized code for boundary checking when adding mineSum