#include #include #include #include #include #include #include #include #include #include #include #include #define vll vector #define vvvl vector #define vvl vector> #define VV(a, b, c, d) vector>(a, vector(b, c)) #define VVV(a, b, c, d) vector(a, vvl(b, vll (c, d))); #define re(c, b) for(ll c=0;c> n; vll a(n-1);get(a); re(i, n){ ll b, c;std::cin >> b >> c; num += c - b; if(i!=n-1) ans += num * a[i]; } std::cout << ans << '\n'; }