using System; public class Hello { public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); var a = new int[n]; var amax = 0L; var asum = 0L; var even = 0; var odd = 0; for (int i = 0; i < n; i++) { string[] line = Console.ReadLine().Trim().Split(' '); var w = int.Parse(line[0]) + 4 * int.Parse(line[1]); asum += w; if (w % 2 == 0) even++; else odd++; amax = Math.Max(amax, w); } if ((amax % 2 == 1 && odd == n) | (amax % 2 == 0 && even == n)) { var w = (asum - amax) * n / 2L; Console.WriteLine(w); } } }