#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int N = 6e5 + 7;
int n, m, q;
long long cw[N];
int ehd[N], ev[N], enx[N], ew[N], eid;
int ord[N], mp[N], tp, Fa[N];
void eadd(int u, int v, int w) {
  ++eid, enx[eid] = ehd[u], ev[eid] = v, ew[eid] = w, ehd[u] = eid;
}
long long dis[N], w[N];
bool vis[N];
int pr[N], No[N], tot;
vector<int> S[N], cno[N];
int all[N];
void Dij() {
  memset(dis, 0x3f, sizeof(dis));
  priority_queue<pair<long long, int> > q;
  q.push({0, 1}), dis[1] = 0;
  while (!q.empty()) {
    int u = q.top().second;
    q.pop();
    if (vis[u]) continue;
    ++tp, ord[tp] = u, mp[u] = tp;
    vis[u] = true;
    for (int i = ehd[u]; i; i = enx[i])
      if (dis[ev[i]] > dis[u] + ew[i])
        dis[ev[i]] = dis[u] + ew[i], q.push({-dis[ev[i]], ev[i]});
  }
  Fa[1] = -1;
  for (int u = (2); u <= (n); ++u) {
    for (int i = ehd[u]; i; i = enx[i])
      if (dis[ev[i]] + ew[i] == dis[u]) {
        if (!Fa[u])
          Fa[u] = ev[i];
        else
          Fa[u] = -1;
      }
    if (Fa[u] == 1) Fa[u] = 0;
  }
  int lst = 0;
  for (int u = (1); u <= (n); ++u) {
    w[u] = cw[ord[u]];
    if (dis[ord[u]] != dis[ord[u - 1]]) lst = u - 1;
    if (Fa[ord[u]] != -1)
      ++tot, pr[tot] = lst, No[tot] = mp[Fa[ord[u]]], all[pr[tot]] += 1;
  }
  for (int i = (1); i <= (n + 2); ++i) all[i] += all[i - 1];
  w[0] = 1e18;
  for (int i = (1); i <= (tot); ++i)
    S[pr[i]].push_back(No[i]), cno[No[i]].push_back(pr[i]);
  for (int i = (0); i <= (n); ++i) sort(cno[i].begin(), cno[i].end());
}
struct Data {
  int mn1, mn2;
  Data(int m1 = 0, int m2 = 0) { mn1 = m1, mn2 = m2; }
  void insert(int i) {
    if (w[mn1] > w[i])
      mn2 = mn1, mn1 = i;
    else if (w[mn2] > w[i])
      mn2 = i;
  }
  friend Data operator+(Data a, Data o) {
    Data ns = a;
    ns.insert(o.mn1);
    ns.insert(o.mn2);
    return ns;
  }
};
Data s[1 << 20];
int Sum;
inline void upd(int x) { s[x] = s[x << 1] + s[x << 1 | 1]; }
inline void build(int id, int l, int r) {
  if (l == r) return s[id] = Data(l, 0), void();
  int mid = (l + r) >> 1;
  build(id << 1, l, mid), build(id << 1 | 1, mid + 1, r);
  upd(id);
}
inline void mdf(int id, int L, int R, int p) {
  if (L == R) return;
  int mid = (L + R) >> 1;
  if (p <= mid)
    mdf(id << 1, L, mid, p);
  else
    mdf(id << 1 | 1, mid + 1, R, p);
  upd(id);
}
inline Data qry1(int id, int L, int R, int l, int r) {
  if (l <= L && R <= r) return s[id];
  int mid = (L + R) >> 1;
  Data ret;
  if (l > mid) return qry1(id << 1 | 1, mid + 1, R, l, r);
  if (r <= mid) return qry1(id << 1, L, mid, l, r);
  return qry1(id << 1, L, mid, l, r) + qry1(id << 1 | 1, mid + 1, R, l, r);
}
inline int gnx(int id, int L, int R, int l, int r, long long W) {
  if (w[s[id].mn1] > W) return -1;
  if (L == R) return L;
  int mid = (L + R) >> 1, ret;
  if (l <= mid && (~(ret = gnx(id << 1, L, mid, l, r, W)))) return ret;
  if (r > mid && (~(ret = gnx(id << 1 | 1, mid + 1, R, l, r, W)))) return ret;
  return -1;
}
__int128 ns;
inline int get(int l, int r, long long x) {
  l = max(l, 1);
  if (l > r) return -1;
  return gnx(1, 1, n, l, r, x);
}
__int128 getv(int x) {
  int lst = get(1, x - 1, w[x]), rst = get(x + 1, n, w[x] - 1);
  if (rst == -1) rst = n + 1;
  if (lst != -1 && get(lst + 1, x - 1, w[x]) != -1) return 0;
  int cnt = 0;
  if (lst != -1) {
    cnt += lower_bound(cno[lst].begin(), cno[lst].end(), rst) -
           lower_bound(cno[lst].begin(), cno[lst].end(), x);
  } else {
    int cst = get(rst + 1, n, w[x] - 1);
    if (cst == -1) cst = n + 1;
    cnt = all[rst - 1] - all[x - 1];
    cnt -= lower_bound(cno[x].begin(), cno[x].end(), rst) -
           lower_bound(cno[x].begin(), cno[x].end(), x);
    cnt += lower_bound(cno[rst].begin(), cno[rst].end(), cst) -
           lower_bound(cno[rst].begin(), cno[rst].end(), rst);
  }
  return (__int128)cnt * w[x];
}
void Dec(int x, int k) {
  Data M;
  if (x > 1) M = qry1(1, 1, n, 1, x - 1);
  vector<int> S;
  if (M.mn1) S.push_back(M.mn1);
  if (M.mn2) S.push_back(M.mn2);
  S.push_back(x);
  M.insert(x);
  int z = x + 1;
  while (z <= n) {
    if (w[M.mn2] < w[x] - k) break;
    int i = get(z, n, min(w[M.mn2], w[x] - 1));
    if (i == -1) break;
    if (w[x] - k <= w[i]) S.push_back(i);
    M.insert(i);
    z = i + 1;
  }
  Sum += ((int)(S).size());
  if (Sum > 1.8e6) assert(0);
  for (const int &t : S) ns -= getv(t);
  w[x] -= k, mdf(1, 1, n, x);
  for (const int &t : S) ns += getv(t);
}
inline __int128 query() {
  for (int i = (1); i <= (n); ++i) ns += getv(i);
  return ns;
}
int sx[N], sk[N];
__int128 nsw[N];
void prt(__int128 x) {
  if (x >= 10) prt(x / 10);
  cout << ((int)(x % 10));
}
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> q;
  for (int i = (1); i <= (n); ++i) cin >> cw[i];
  for (int i = (1); i <= (m); ++i) {
    int u, v, d;
    cin >> u >> v >> d;
    eadd(u, v, d);
    eadd(v, u, d);
  }
  Dij();
  for (int i = (1); i <= (q); ++i) cin >> sx[i] >> sk[i], sx[i] = mp[sx[i]];
  for (int i = (1); i <= (q); ++i) w[sx[i]] += sk[i];
  build(1, 1, n);
  nsw[q + 1] = query();
  for (int i = (q); i >= (1); --i) Dec(sx[i], sk[i]), nsw[i] = ns;
  for (int i = (1); i <= (q + 1); ++i) prt(nsw[i]), cout << '\n';
  return 0;
}

### Prompt

Please formulate a CPP solution to the following problem:

Because the railway system in Gensokyo is often congested, as an enthusiastic engineer, Kawasiro Nitori plans to construct more railway to ease the congestion.

There are n stations numbered from 1 to n and m two-way railways in Gensokyo. Every two-way railway connects two different stations and has a positive integer length d. No two two-way railways connect the same two stations. Besides, it is possible to travel from any station to any other using those railways. Among these n stations, station 1 is the main station. You can get to any station from any other station using only two-way railways.

Because of the technological limitation, Nitori can only construct one-way railways, whose length can be arbitrary positive integer. Constructing a one-way railway from station u will costs w_u units of resources, no matter where the railway ends. To ease the congestion, Nitori plans that after construction there are at least two shortest paths from station 1 to any other station, and these two shortest paths do not pass the same station except station 1 and the terminal. Besides, Nitori also does not want to change the distance of the shortest path from station 1 to any other station.

Due to various reasons, sometimes the cost of building a new railway will increase uncontrollably. There will be a total of q occurrences of this kind of incident, and the i-th event will add additional amount of x_i to the cost of building a new railway from the station k_i.

To save resources, before all incidents and after each incident, Nitori wants you to help her calculate the minimal cost of railway construction.

Input

The first line contains three integers n, m, and q (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ m ≤ 3 ⋅ 10^5, 0 ≤ q ≤ 2⋅10^5).

The second line contains n integers w_1,w_2,…,w_n (1 ≤ w_i ≤ 10^9).

Each of the next m lines contains three integers u, v, d (1 ≤ u,v ≤ n, u ≠ v, 1 ≤ d ≤ 10^9), denoting a two-way railway connecting station u and station v, with length d.

The i-th of the next q lines contains two integers k_i,x_i (1 ≤ k_i ≤ n, 1 ≤ x_i ≤ 4 × 10^8).

Output

Print q+1 lines, and the i-th of these lines contains one integer, denoting the minimal cost of railway construction after the i-1-th incident (especially, the 0-th incident means no incident occurred).

Examples

Input


5 5 1
1 1 1 1 1
1 2 1
2 3 1
2 4 1
3 5 1
4 5 1
1 2


Output


3
9


Input


8 11 0
14 4 16 15 1 3 1 14
4 2 1
1 2 3
7 5 4
2 3 1
8 6 2
8 5 5
5 4 5
7 6 7
3 5 5
1 6 6
8 1 4


Output


46


Input


10 16 8
29 1 75 73 51 69 24 17 1 97
1 2 18
2 3 254
2 4 546
2 5 789
5 6 998
6 7 233
7 8 433
1 9 248
5 10 488
2 6 1787
10 8 1176
3 8 2199
4 8 1907
2 10 1277
4 10 731
9 10 1047
1 11
1 9
8 8
1 3
2 19
9 5
9 4
7 6


Output


34
45
54
54
57
76
96
112
112

Note

In the second example, Nitori can build railways as follows: 1 → 2, 1 → 3, 1 → 4, 2 → 8, and the cost is 14 + 14 + 14 + 4 = 46.

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int N = 6e5 + 7;
int n, m, q;
long long cw[N];
int ehd[N], ev[N], enx[N], ew[N], eid;
int ord[N], mp[N], tp, Fa[N];
void eadd(int u, int v, int w) {
  ++eid, enx[eid] = ehd[u], ev[eid] = v, ew[eid] = w, ehd[u] = eid;
}
long long dis[N], w[N];
bool vis[N];
int pr[N], No[N], tot;
vector<int> S[N], cno[N];
int all[N];
void Dij() {
  memset(dis, 0x3f, sizeof(dis));
  priority_queue<pair<long long, int> > q;
  q.push({0, 1}), dis[1] = 0;
  while (!q.empty()) {
    int u = q.top().second;
    q.pop();
    if (vis[u]) continue;
    ++tp, ord[tp] = u, mp[u] = tp;
    vis[u] = true;
    for (int i = ehd[u]; i; i = enx[i])
      if (dis[ev[i]] > dis[u] + ew[i])
        dis[ev[i]] = dis[u] + ew[i], q.push({-dis[ev[i]], ev[i]});
  }
  Fa[1] = -1;
  for (int u = (2); u <= (n); ++u) {
    for (int i = ehd[u]; i; i = enx[i])
      if (dis[ev[i]] + ew[i] == dis[u]) {
        if (!Fa[u])
          Fa[u] = ev[i];
        else
          Fa[u] = -1;
      }
    if (Fa[u] == 1) Fa[u] = 0;
  }
  int lst = 0;
  for (int u = (1); u <= (n); ++u) {
    w[u] = cw[ord[u]];
    if (dis[ord[u]] != dis[ord[u - 1]]) lst = u - 1;
    if (Fa[ord[u]] != -1)
      ++tot, pr[tot] = lst, No[tot] = mp[Fa[ord[u]]], all[pr[tot]] += 1;
  }
  for (int i = (1); i <= (n + 2); ++i) all[i] += all[i - 1];
  w[0] = 1e18;
  for (int i = (1); i <= (tot); ++i)
    S[pr[i]].push_back(No[i]), cno[No[i]].push_back(pr[i]);
  for (int i = (0); i <= (n); ++i) sort(cno[i].begin(), cno[i].end());
}
struct Data {
  int mn1, mn2;
  Data(int m1 = 0, int m2 = 0) { mn1 = m1, mn2 = m2; }
  void insert(int i) {
    if (w[mn1] > w[i])
      mn2 = mn1, mn1 = i;
    else if (w[mn2] > w[i])
      mn2 = i;
  }
  friend Data operator+(Data a, Data o) {
    Data ns = a;
    ns.insert(o.mn1);
    ns.insert(o.mn2);
    return ns;
  }
};
Data s[1 << 20];
int Sum;
inline void upd(int x) { s[x] = s[x << 1] + s[x << 1 | 1]; }
inline void build(int id, int l, int r) {
  if (l == r) return s[id] = Data(l, 0), void();
  int mid = (l + r) >> 1;
  build(id << 1, l, mid), build(id << 1 | 1, mid + 1, r);
  upd(id);
}
inline void mdf(int id, int L, int R, int p) {
  if (L == R) return;
  int mid = (L + R) >> 1;
  if (p <= mid)
    mdf(id << 1, L, mid, p);
  else
    mdf(id << 1 | 1, mid + 1, R, p);
  upd(id);
}
inline Data qry1(int id, int L, int R, int l, int r) {
  if (l <= L && R <= r) return s[id];
  int mid = (L + R) >> 1;
  Data ret;
  if (l > mid) return qry1(id << 1 | 1, mid + 1, R, l, r);
  if (r <= mid) return qry1(id << 1, L, mid, l, r);
  return qry1(id << 1, L, mid, l, r) + qry1(id << 1 | 1, mid + 1, R, l, r);
}
inline int gnx(int id, int L, int R, int l, int r, long long W) {
  if (w[s[id].mn1] > W) return -1;
  if (L == R) return L;
  int mid = (L + R) >> 1, ret;
  if (l <= mid && (~(ret = gnx(id << 1, L, mid, l, r, W)))) return ret;
  if (r > mid && (~(ret = gnx(id << 1 | 1, mid + 1, R, l, r, W)))) return ret;
  return -1;
}
__int128 ns;
inline int get(int l, int r, long long x) {
  l = max(l, 1);
  if (l > r) return -1;
  return gnx(1, 1, n, l, r, x);
}
__int128 getv(int x) {
  int lst = get(1, x - 1, w[x]), rst = get(x + 1, n, w[x] - 1);
  if (rst == -1) rst = n + 1;
  if (lst != -1 && get(lst + 1, x - 1, w[x]) != -1) return 0;
  int cnt = 0;
  if (lst != -1) {
    cnt += lower_bound(cno[lst].begin(), cno[lst].end(), rst) -
           lower_bound(cno[lst].begin(), cno[lst].end(), x);
  } else {
    int cst = get(rst + 1, n, w[x] - 1);
    if (cst == -1) cst = n + 1;
    cnt = all[rst - 1] - all[x - 1];
    cnt -= lower_bound(cno[x].begin(), cno[x].end(), rst) -
           lower_bound(cno[x].begin(), cno[x].end(), x);
    cnt += lower_bound(cno[rst].begin(), cno[rst].end(), cst) -
           lower_bound(cno[rst].begin(), cno[rst].end(), rst);
  }
  return (__int128)cnt * w[x];
}
void Dec(int x, int k) {
  Data M;
  if (x > 1) M = qry1(1, 1, n, 1, x - 1);
  vector<int> S;
  if (M.mn1) S.push_back(M.mn1);
  if (M.mn2) S.push_back(M.mn2);
  S.push_back(x);
  M.insert(x);
  int z = x + 1;
  while (z <= n) {
    if (w[M.mn2] < w[x] - k) break;
    int i = get(z, n, min(w[M.mn2], w[x] - 1));
    if (i == -1) break;
    if (w[x] - k <= w[i]) S.push_back(i);
    M.insert(i);
    z = i + 1;
  }
  Sum += ((int)(S).size());
  if (Sum > 1.8e6) assert(0);
  for (const int &t : S) ns -= getv(t);
  w[x] -= k, mdf(1, 1, n, x);
  for (const int &t : S) ns += getv(t);
}
inline __int128 query() {
  for (int i = (1); i <= (n); ++i) ns += getv(i);
  return ns;
}
int sx[N], sk[N];
__int128 nsw[N];
void prt(__int128 x) {
  if (x >= 10) prt(x / 10);
  cout << ((int)(x % 10));
}
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> q;
  for (int i = (1); i <= (n); ++i) cin >> cw[i];
  for (int i = (1); i <= (m); ++i) {
    int u, v, d;
    cin >> u >> v >> d;
    eadd(u, v, d);
    eadd(v, u, d);
  }
  Dij();
  for (int i = (1); i <= (q); ++i) cin >> sx[i] >> sk[i], sx[i] = mp[sx[i]];
  for (int i = (1); i <= (q); ++i) w[sx[i]] += sk[i];
  build(1, 1, n);
  nsw[q + 1] = query();
  for (int i = (q); i >= (1); --i) Dec(sx[i], sk[i]), nsw[i] = ns;
  for (int i = (1); i <= (q + 1); ++i) prt(nsw[i]), cout << '\n';
  return 0;
}

```