Idea: Ah, esto, no es solo un problema de agua, sino que Java Caigou tiene que buscar entradas y salidas..
Código:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int ans = 0, x, y;
for(int i = 0; i < n; i ++){
x = input.nextInt();
y = input.nextInt();
ans += x*y;
}
System.out.println(Math.max(ans, 0));
}
}