require 'bigdecimal' n = gets.to_i a = [] n.times do s = gets.chomp unless /^([-]?)(\d+)(?:[.](\d+))?$/o =~ s warn 'must not happen' exit 1 end sign = $1 i, d = "#{sign}#{$2}", "#{sign}0.#{$3 || 0}" a << [i.to_i, BigDecimal(d)] end int = a.map{|i, d| i }.inject(:+) decimal = a.map{|i, d| d }.inject(:+) d_int = decimal.to_i int += d_int decimal -= d_int s_decimal = (sprintf "%.10f", decimal.abs)[2..-1] puts "#{int}.#{s_decimal}"