#include #include using namespace std; int main() { int n,m = 0,b,c,num=0,e; 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; }