#include #include using namespace std; int main() { int n,b,c,e,num=0;long long m = 0; cin >> n; vector a; for(int d = 0;d> e; a.push_back(e); } for(int d = 0;d> b >> c; num += c - b; if(d != n-1)m += num*a[d]; } cout << m << "\n"; return -1; }