Simplify with inject:
arr.inject(0){|sum, x| sum +x}