class Deposit attr_reader :n, :c def initialize(n: 0, c: []) @n, @c = n, c end def cause begin @n = Integer(gets.chomp) @c = gets.chomp.split.map { |v| Integer(v) } rescue end end def deposit(array) r = 0 array.each do |i| r += 30 if i <= (array.inject(:+)/10) end r end def result puts deposit(@c) end def run cause result end end if $0 == __FILE__ Deposit.new.run end