using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; class Magatro { static int N = int.Parse(Console.ReadLine()); static void Main() { Number Plus=new Number("0.0"), Minus=new Number("-0.0"); for(int i = 0; i < N; i++) { Number read = new Number(Console.ReadLine()); // Console.WriteLine(read.toString()); if (read.Positive) { Plus += read; } else { Minus += read; } } Console.WriteLine((Plus + Minus).toString()); } } struct Number { public bool Positive; public long Integer, Fraction; public Number(string s) { Number r = new Number(); r.Positive = s[0] != '-'; if (!r.Positive) s = s.Remove(0, 1); string[] q = s.Split('.'); r.Integer = long.Parse(q[0]); if (q.Length == 1) { r.Fraction = 0; } else { r.Fraction = long.Parse(q[1].PadRight(10, '0')); } Positive = r.Positive ; Integer = r.Integer; Fraction = r.Fraction; } public string toString() { string ret = ""; if (!Positive) { ret = "-"; } ret += Integer.ToString(); ret += "."; ret += Fraction.ToString().PadRight(10, '0'); return ret; } public static Number operator +(Number a,Number b) { if (a.Positive && b.Positive) { Number r = new Number(); r.Positive = true; r.Integer = a.Integer + b.Integer; r.Fraction = a.Fraction + b.Fraction; r.Integer += r.Fraction / 10000000000; r.Fraction %= 10000000000; return r; } else if (!a.Positive && !b.Positive) { Number ca = a, cb = b; ca.Positive = true; cb.Positive = true; Number r = ca + cb; r.Positive = false; return r; } else if(!a.Positive&&b.Positive) { Number ca = new Number(); ca.Integer = -a.Integer + b.Integer; ca.Fraction = -a.Fraction + b.Fraction; ca.Integer += ca.Fraction / 10000000000; ca.Fraction %= 10000000000; if (ca.Integer > 0) { ca.Positive = true; if (ca.Fraction < 0) { ca.Integer--; ca.Fraction += 10000000000; } return ca; } else if (ca.Integer < 0) { ca.Positive = false; if (ca.Fraction > 0) { ca.Integer++; ca.Fraction -= 10000000000; ca.Fraction *= -1; } ca.Integer *= -1; return ca; } else { if (ca.Fraction >= 0) { ca.Positive = true; } else { ca.Positive = false; ca.Fraction *= -1; } return ca; } } else { Number ca = new Number(); ca = b+a; return ca; } } }