Calculate sum