using System; using System.Collections.Generic; using System.Linq; namespace y { class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var li1 = new List(); li1.Add(new int[] { 0, 0 }); for (int i = 0; i < n; i++) { var li2 = new List(); var num = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); foreach (var item in li1) { li2.Add(new int[] { item[0] + num[0], item[1] }); li2.Add(new int[] { item[0], item[1] + num[1] }); } li1 = li2; } var ans = li1.Min(x => Math.Abs( x[0] - x[1])); Console.WriteLine(ans); } } }