class FindTotalValue2 attr_reader :n, :a def initialize(n: 0, a: []) @n, @a = n, a end def datainput begin @n = Integer(gets.chomp) @a = @n.times.map { Integer(gets.chomp) } rescue end end def dataoutput puts @a.inject(:+) end def run datainput dataoutput end end if $0 == __FILE__ FindTotalValue2.new.run end