import java.io.*; import java.util.*; public class Main_yukicoder633 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); int[] a = new int[n - 1]; for (int i = 0; i < n - 1; i++) { a[i] = sc.nextInt(); } int[] b = new int[n]; int[] c = new int[n]; for (int i = 0; i < n; i++) { b[i] = sc.nextInt(); c[i] = sc.nextInt(); } int ans = 0; int num = 0; for (int i = 0; i < n; i++) { if (i > 0) { ans += num * a[i - 1]; } num += c[i]; num -= b[i]; } pr.println(ans); } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }