#include #include #include #include template using min_priority_queue = std::priority_queue, std::greater>; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n, m; long long c; std::cin >> n >> m >> c; std::vector a(n); for (auto& e : a) { std::cin >> e; } std::vector> rs(n + 1); for (int i = 0; i < m; ++i) { int l, r; std::cin >> l >> r; --l; rs[l].push_back(r); } long long s = std::accumulate(a.begin(), a.end(), 0LL); min_priority_queue> pq; std::vector d(n + 1, 1LL << 60); pq.emplace(d[0] = 0, 0); while (pq.size()) { auto [du, u] = pq.top(); pq.pop(); if (du != d[u]) continue; auto update = [&](int v, long long cost) { if (d[v] > du + cost) pq.emplace(d[v] = du + cost, v); }; if (u != 0) update(u - 1, a[u - 1]); if (u != n) update(u + 1, a[u]); for (int r : rs[u]) update(r, c); } std::cout << s - d[n] << std::endl; }