import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n - 1]; int[] b = new int[n]; int[] c = new int[n]; for(int i = 0; i < n - 1; i++) { a[i] = sc.nextInt(); } for(int i = 0; i < n; i++) { if(i == 0) { b[i] = sc.nextInt(); c[i] = sc.nextInt(); } else { b[i] = (b[i - 1] + sc.nextInt()); c[i] = (c[i - 1] + sc.nextInt()); } } int ans = 0; for(int i = 0; i < n - 1; i++) { ans += ((a[i]) * (c[i] - b[i])); } } }