package Yukicoder import java.math.BigDecimal /** * Created by hichikawa on 2015/11/12. */ fun main(args: Array) { fun readLineLongArray(): List { val str = readLine() as String val arrStr = str.split(".") val ret = arrStr.map { it.toLong() } return ret } fun readLineLong(): Long { val str = readLine() as String return str.toLong() } fun readLineInt(): Int { val str = readLine() as String return str.toInt() } fun readLineDouble(): Double { val str = readLine() as String return str.toDouble() } fun readLineIntArray() : List { val str = readLine() as String val arrStr = str.split(" ") val ret = arrStr.map { it.toInt() } return ret } fun readLineDoubleArray(): List { val str = readLine() as String val arrStr = str.split(".") val ret = arrStr.map { it.toDouble() } return ret } val num = readLineInt() var list = Array(num, {Array(2, {0})}) for (i in 0..(num-1)) { val str = readLine() as String if (str.indexOf(".") != -1) { val plmi : Int = if (str.get(0) == '-') -1 else 1 val arrStr = str.split("\\.") val tmp = arrStr.map { it.toLong() } list[i][0] = tmp[0] list[i][1] = tmp[1] * Math.pow(10.toDouble(), (10-arrStr[1].length).toDouble()).toLong() * plmi } else { list[i][0] = str.toLong() } } var ans1 : Long = 0.toLong() var ans2 : Long = 0.toLong() for (item in list) { ans1 += item[0] ans2 += item[1] } // println(ans1) // println(ans2) ans1 += ans2 / 10000000000 ans2 = ans2 % 10000000000 // println(ans1) // println(ans2) if (ans1 >= 0 && ans2 > 0) { println(ans1.toString() + "." + java.lang.String.format("%010d",ans2)) } else if (ans1 < 0 && ans2 < 0) { println(ans1.toString() + "." + java.lang.String.format("%010d",ans2*-1)) } else if (ans1 > 0 && ans2 < 0) { println((ans1-1).toString() + "." + java.lang.String.format("%010d",(10000000000+ans2))) } else if (ans1 < 0 && ans2 > 0) { println((ans1+1).toString() + "." + java.lang.String.format("%010d",(10000000000-ans2))) } else if (ans1 == 0.toLong() && ans2 < 0) { println("-" + (ans1).toString() + "." + java.lang.String.format("%010d",(ans2*-1)).toString()) } else if (ans2 == 0.toLong()) { println(ans1.toString() + "." + java.lang.String.format("%010d",ans2)) } }