#include using namespace std; int main(void){ int n,a[100]; cin >> n; for(int i=0;i> a[i]; int user=0,cost=0; for(int i=0;i> b >> c; user += c-b; cost += a[i]*user; } cout << cost << endl; }