def sum(n) sum = 0 range = (0...n) arr = gets.split.map(&:to_i) range.each do |i| sum += arr[i] end puts sum end sum(gets.to_i)