#include #include using namespace std; int main() { int n,b,c,num=0,e,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; m += num*a[d]; } cout << m << "\n"; return -1; }