#include using namespace std; int main(int argc, char const* argv[]) { int n; cin>>n; vector a(n),b(n),c(n); int ans=0; int zyoukyaku=0; for (int i = 0; i < n-1; i++) { cin>>a[i]; } for (int i = 0; i < n; i++) { cin>>b[i]>>c[i]; b[0]=c[n]=0; zyoukyaku=zyoukyaku+c[n]-b[n]; if(i>0){ ans=ans+(a[n-1]*b[n]); } } cout<