using System; public class Hello { static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); var b = new int[n]; for (int i = 0; i < n; i++) b[i] = a[2 * i] - a[2 * i + 1]; Console.WriteLine(getAns(n, b)); } static long getAns(int n, int[] a) { var ans = 0L; var L = 0; var r = n - 1; for (int i = 0; i < n; i++) { if (a[L] >= -a[r]) { ans += a[L]; L++; } else { ans += -a[r]; r--; } } return ans; } }