def array_sum(space, w_arr):
    """ Calculate the sum of values in an array """
    res = 0
    is_float = False
    with space.iter(w_arr) as itr:
        while not itr.done():
            _, w_val = itr.next_item(space)
            w_val_n = space.as_number(w_val)
            if w_val_n.tp == space.tp_float:
                res += space.float_w(w_val_n)
                is_float = True
            else:
                res += space.int_w(w_val_n)
    if is_float:
        return space.newfloat(res)
    return space.newint(int(res))