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 << [BigDecimal(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 printf "%d.%010d\n", int, (decimal.abs * (10 ** 10))