#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <vector>
#include <queue>
#define int long long
using namespace std;
inline int read();
void write(int);
void writeln(int);
const int N = 1000005;
int n, m, qwq, a[N], dep[N], sum[N], maxd = -1;
int gcd(int x, int y) {
return y == 0 ? x : gcd(y, x % y);
}
int max(int x, int y) {
return x > y ? x : y;
}
struct SegmentTree {
int tree[N << 2], lzy[N << 2];
void pushup(int u) { tree[u] = tree[u << 1] + tree[u << 1 | 1]; }
void build(int u, int l, int r, int d) {
if(l == r) {
tree[u] = a[l];
dep[l] = d;
maxd = max(maxd, d);
return ;
}
int mid = (l + r) >> 1;
build(u << 1, l, mid, d + 1);
build(u << 1 | 1, mid + 1, r, d + 1);
pushup(u);
}
int query(int u, int l, int r, int t, int res) {
if(l == r) return (int)(res + tree[u]) * (1 << t);
int mid = (l + r) >> 1;
int ls = query(u << 1, l, mid, t - 1, res + tree[u]);
int rs = query(u << 1 | 1, mid + 1, r, t - 1, res + tree[u]);
return ls + rs;
}
} c;
signed main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
n = read();
m = read();
qwq = read();
for(int i = 1; i <= n; i++) a[i] = read();
c.build(1, 1, n, 1);
int ans = c.query(1, 1, n, maxd - 1, 0);
int tmp = (1 << (maxd - 1));
int g = gcd(tmp, qwq);
tmp = tmp / g, qwq = qwq / g;
for(int i = 1; i <= n; i++)
sum[i] = sum[i - 1] + (((1 << dep[i]) - 1) << (maxd - dep[i]));
while(m--) {
int l = read(), r = read(), w = read();
ans = ans + (sum[r] - sum[l - 1]) * w;
writeln(ans / tmp * qwq);
}
// printf("\n");
// cout<<"The time used: ";
// printf("%.2lfs",(double)clock()/CLOCKS_PER_SEC);
return 0;
}
inline int read() {
int res = 0, f = 1;
char ch = getchar();
while( !(ch >= '0' && ch <= '9') ) {
if(ch == '-') f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9') {
res = (res << 1) + (res << 3) + (ch ^ 48);
ch = getchar();
}
return res * f;
}
void write(int x) {
static int sta[64];
int top = 0;
do {
sta[top++] = x % 10;
x /= 10;
} while(x);
while(top) putchar(sta[--top] ^ 48);
}
void writeln(int x) {
write(x);
putchar('\n');
}