Input validation for sum