user
Write a function that calculates the sum of the numbers in a given array
[1, 7, 4, -2, 9]

assistant
def sum_array(array):
    total_sum = 0
    for num in array:
        total_sum += num
    return total_sum