Create an algorithm in Python that computes the sum of an array
[10, 20, 30, 40]
def array_sum(arr):
    sum = 0
    for num in arr:
        sum += num
    return sum

print(array_sum([10, 20, 30, 40]))

# Output: 100