import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n + 2]; long[] left = new long[n + 2]; for (int i = 1; i <= n; i++) { arr[i] = sc.nextInt() - sc.nextInt(); left[i] = left[i - 1] + arr[i]; } long[] right = new long[n + 2]; for (int i = n; i >= 1; i--) { right[i] = right[i + 1] - arr[i]; } long max = Long.MIN_VALUE; for (int i = 0; i <= n; i++) { max = Math.max(max, left[i] + right[i + 1]); } System.out.println(max); } }