Create a Python program that takes in a list of numbers and outputs the sum of itself and all its previous numbers (including the number itself).
[2, 3, 4, 5, 6]
def sum_of_all(nums):
    sum = 0
    for i in range(len(nums)):
        sum += sum(nums[:i+1])
    return sum

#Test
print(sum_of_all([2, 3, 4, 5, 6])) # Output: 20