N = int(input()) A = [int(input()) for _ in range(N - 1)] B, C = [0] * N, [0] * N for i in range(N): B[i], C[i] = map(int, input().split()) X = C[0] ans = 0 for i in range(N - 1): ans += X * A[i] X = X - B[i + 1] + C[i + 1] print(ans)