Fixed arraySum function