import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(reader.readLine()); String[] str = reader.readLine().split(" "); int[] n = new int[2*N]; for (int i = 0; i < 2*N; i++) { n[i] = Integer.parseInt(str[i]); } int max = 0; for (int b = 0; b < N; b++) { //しきり int keep = 0; for (int a = 0; a < N; a++) { //中の数 if (a <= b) { keep += n[2*a] - n[2*a+1]; } else { keep += n[2*a+1] - n[2*a]; } } keep = Math.abs(keep); if (keep > max) { max = keep; } } System.out.println(max); } }