def sum(n) list = [] sum = 0 range = (0...n) range.each do |i| list[i] = gets.to_i sum += list[i] end puts sum end sum(gets.to_i)