user
You need to complete the following task:

Generate a correct program to calculate the sum of all elements of an array


assistant
def array_sum(arr):
    sum = 0
    for n in arr:
        sum += n
    return sum