Problem: In the Kingdom of IOI, the wind always blows from sea to land. There are $N + 1$ spots numbered from $0$ to $N$. The wind from Spot $0$ to Spot $N$ in order. Mr. JOI has a house at Spot $N$. The altitude of Spot $0$ is $A_0 = 0$, and the altitude of Spot $i$ ($1 \leq i \leq N$) is $A_i$.

The wind blows on the surface of the ground. The temperature of the wind changes according to the change of the altitude. The temperature of the wind at Spot $0$, which is closest to the sea, is $0$ degree. For each $i$ ($0 \leq i \leq N - 1$), the change of the temperature of the wind from Spot $i$ to Spot $i + 1$ depends only on the values of $A_i$ and $A_{i+1}$ in the following way:

* If $A_i < A_{i+1}$, the temperature of the wind decreases by $S$ degrees per altitude.
* If $A_i \geq A_{i+1}$, the temperature of the wind increases by $T$ degrees per altitude.



The tectonic movement is active in the land of the Kingdom of IOI. You have the data of tectonic movements for $Q$ days. In the $j$-th ($1 \leq j \leq Q$) day, the change of the altitude of Spot $k$ for $L_j \leq k \leq R_j$ ($1 \leq L_j \leq R_j \leq N$) is described by $X_j$. If $X_j$ is not negative, the altitude increases by $X_j$. If $X_j$ is negative, the altitude decreases by $|X_j|$.

Your task is to calculate the temperature of the wind at the house of Mr. JOI after each tectonic movement.

Task

Given the data of tectonic movements, write a program which calculates, for each $j$ ($1 \leq j \leq Q$), the temperature of the wind at the house of Mr. JOI after the tectonic movement on the $j$-th day.

Input

Read the following data from the standard input.

* The first line of input contains four space separated integers $N$, $Q$, $S$, $T$. This means there is a house of Mr. JOI at Spot $N$, there are $Q$ tectonic movements, the temperature of the wind decreases by $S$ degrees per altitude if the altitude increases, and the temperature of the wind increases by $T$ degrees per altitude if the altitude decreases.
* The $i$-th line ($1 \leq i \leq N +1$) of the following $N +1$ lines contains an integer $A_{i-1}$, which is the initial altitude at Spot ($i - 1$) before tectonic movements.
* The $j$-th line ($1 \leq j \leq Q$) of the following $Q$ lines contains three space separated integers $L_j$, $R_j$, $X_j$. This means, for the tectonic movement on the $j$-th day, the change of the altitude at the spots from $L_j$ to $R_j$ is described by $X_j$.



Output

Write $Q$ lines to the standard output. The $j$-th line ($1 \leq j \leq Q$) of output contains the temperature of the wind at the house of Mr. JOI after the tectonic movement on the $j$-th day.

Constraints

All input data satisfy the following conditions.

* $1 \leq N \leq 200 000．$
* $1 \leq Q \leq 200 000．$
* $1 \leq S \leq 1 000 000．$
* $1 \leq T \leq 1 000 000．$
* $A_0 = 0．$
* $-1 000 000 \leq A_i \leq 1 000 000 (1 \leq i \leq N)．$
* $1 \leq L_j \leq R_j \leq N (1 \leq j \leq Q)．$
* $ -1 000 000 \leq X_j \leq 1 000 000 (1 \leq j \leq Q)．$



Sample Input and Output

Sample Input 1


3 5 1 2
0
4
1
8
1 2 2
1 1 -2
2 3 5
1 2 -1
1 3 5


Sample Output 1


-5
-7
-13
-13
-18


Initially, the altitudes of the Spot 0, 1, 2, 3 are 0, 4, 1, 8, respectively. After the tectonic movement on the first day, the altitudes become 0, 6, 3, 8, respectively. At that moment, the temperatures of the wind are 0, -6, 0, -5,respectively.

Sample Input 2


2 2 5 5
0
6
-1
1 1 4
1 2 8


Sample Output 2


5
-35


Sample Input 3


7 8 8 13
0
4
-9
4
-2
3
10
-9
1 4 8
3 5 -2
3 3 9
1 7 4
3 5 -1
5 6 3
4 4 9
6 7 -10


Sample output 3


277
277
322
290
290
290
290
370





Creatie Commons License

The 16th Japanese Olympiad in Informatics (JOI 2016/2017) Final Round





Example

Input

3 5 1 2
0
4
1
8
1 2 2
1 1 -2
2 3 5
1 2 -1
1 3 5


Output

-5
-7
-13
-13
-18

Solution (in CPP):

Solution:
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>

const int SIZE = 1<<18;
using namespace std;  // XXX
template <class T>
struct segtree {
  T node[2*SIZE], lazy[2*SIZE], I_upd, I_qry;
  bool need_upd[2*SIZE];
  T (*upd_f)(T, T, int, int), (*qry_f)(T, T);

  segtree(T (*op1)(T, T, int, int), T (*op2)(T, T), T X_upd, T X_qry) {
    upd_f = op1;
    qry_f = op2;
    I_upd = X_upd;
    I_qry = X_qry;
    fill(lazy, lazy+2*SIZE, I_upd);
    fill(node, node+2*SIZE, I_qry);
    fill(need_upd, need_upd+2*SIZE, false);
  }

  void init(const vector<T>& vec) {
    int N = vec.size();
    for (int i=0; i<N; ++i)
      node[SIZE-1+i] = vec[i];
    for (int i=SIZE-2; i>=0; --i)
      node[i] = qry_f(node[2*i+1], node[2*i+2]);
  }

  void lazy_eval(int k, int l, int r) {
    if (!need_upd[k]) return;
    node[k] = upd_f(node[k], lazy[k], l, r);
    if (r-l > 1) {
      lazy[2*k+1] = upd_f(lazy[2*k+1], lazy[k], 0, 1);
      lazy[2*k+2] = upd_f(lazy[2*k+2], lazy[k], 0, 1);
      need_upd[2*k+1] = need_upd[2*k+2] = true;
    }
    lazy[k] = I_upd;
    need_upd[k] = false;
  }

  void update(int a, int b, T val, int l=0, int r=SIZE, int k=0) {
    lazy_eval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] = upd_f(lazy[k], val, 0, 1);
      need_upd[k] = true;
      lazy_eval(k, l, r);
    } else {
      int mid = (l+r)/2;
      update(a, b, val, l, mid, 2*k+1);
      update(a, b, val, mid, r, 2*k+2);
      node[k] = qry_f(node[2*k+1], node[2*k+2]);
    }
  }

  T query(int a, int b, int l=0, int r=SIZE, int k=0) {
    lazy_eval(k, l, r);
    if (b <= l || r <= a) return I_qry;
    if (a <= l && r <= b) return node[k];
    int mid = (l+r)/2;
    T vl = query(a, b, l, mid, 2*k+1);
    T vr = query(a, b, mid, r, 2*k+2);
    return qry_f(vl, vr);
  }
};

intmax_t upd(intmax_t a, intmax_t b, int l, int r) {
  return a + (r-l)*b;
}

intmax_t fnd(intmax_t a, intmax_t b) {
  return a+b;
}

intmax_t foehn(intmax_t S, intmax_t T, intmax_t left, intmax_t right) {
  if (left < right) {
    return -S * (right-left);
  } else {
    return T * (left-right);
  }
}

segtree<intmax_t> sg(upd, fnd, 0, 0);

int main() {
  size_t N, Q;
  intmax_t S, T;
  scanf("%zu %zu %jd %jd", &N, &Q, &S, &T);

  std::vector<intmax_t> H(N+1);
  for (size_t i=0; i<=N; ++i)
    scanf("%jd", &H[i]);

  // std::vector<intmax_t> L(Q), R(Q), X(Q);
  // for (size_t i=0; i<Q; ++i)
  //   scanf("%jd %jd %jd", &L[i], &R[i], &X[i]);

  for (size_t i=0; i<=N; ++i) {
    sg.update(i, i+1, H[i]);
  }

  intmax_t init = 0;
  for (size_t i=1; i<=N; ++i) {
    intmax_t left = sg.query(i-1, i);
    intmax_t right = sg.query(i, i+1);
    init += foehn(S, T, left, right);
  }

  intmax_t res = init;
  for (size_t i=0; i<Q; ++i) {
    int L, R;
    intmax_t X;
    scanf("%d %d %jd", &L, &R, &X);

    {
      intmax_t l0 = sg.query(L-1, L);
      intmax_t l1 = sg.query(L, L+1);
      res -= foehn(S, T, l0, l1);
    }
    if (R < N) {
      intmax_t r0 = sg.query(R, R+1);
      intmax_t r1 = sg.query(R+1, R+2);
      res -= foehn(S, T, r0, r1);
    }

    sg.update(L, R+1, X);
    
    {
      intmax_t l0 = sg.query(L-1, L);
      intmax_t l1 = sg.query(L, L+1);
      res += foehn(S, T, l0, l1);
    }
    if (R < N) {
      intmax_t r0 = sg.query(R, R+1);
      intmax_t r1 = sg.query(R+1, R+2);
      res += foehn(S, T, r0, r1);
    }

    // for (size_t j=0; j<=N; ++j)
    //   fprintf(stderr, "%jd%c", sg.query(j, j+1), j<N? ' ':'\n');

    printf("%jd\n", res);
  }
}