calculate the sum of a list in prolog