// No.633 バスの運賃 // https://yukicoder.me/problems/no/633 // #include #include using namespace std; int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); unsigned int n; cin >> n; vector fees(n, 0); for (auto i = 1; i < n; ++i) cin >> fees[i]; int passenger = 0; int total_fee = 0; for (auto i = 0; i < n; ++i) { total_fee += passenger * fees[i]; int b, c; cin >> b >> c; passenger -= b; passenger += c; } cout << total_fee << endl; }