https://www.acmicpc.net/problem/2455
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
int sum=0;
int max=0;
for(int i=0;i<4;i++){
int a=s.nextInt();
int b=s.nextInt();
sum+=-a+b;
if(sum>=max) max=sum;
}
System.out.print(max);
}
}