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 = false; var odd = false; 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 = true; else odd = true; amax = Math.Max(amax, w); } if ((amax % 2 == 0 && odd) | (amax % 2 == 1 && even)) { Console.WriteLine(-1); goto end; } var ans = (asum - amax) / 2L; Console.WriteLine(ans); end:; } }