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