import java.io.*;
import java.util.*;

public class water_av_sqrt {

	FastScanner in;
	PrintWriter out;

	void solve() {
		int n = in.nextInt(), max = in.nextInt(), q = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		
		final int SQROOT = (int) Math.sqrt(n);
		final int COUNT = (n + SQROOT - 1) / 2;
				
		int[][] blocks = new int[COUNT][];
		int[][] sortedBlocks = new int[COUNT][];
		long[][] prefixSum = new long[COUNT][];
		int[] ptr = new int[COUNT];
		int[] addAll = new int[COUNT];
		
		for (int i = 0; i < blocks.length; i++) {
			int l = i * SQROOT, r = Math.min(l + SQROOT, n) - 1;
			blocks[i] = new int[r - l + 1];
			sortedBlocks[i] = new int[r - l + 1];
			prefixSum[i] = new long[r - l + 1];

			for (int j = l; j <= r; j++) {
				blocks[i][j - l] = a[j];
			}
			
			rebuildBlock(blocks[i], sortedBlocks[i], prefixSum[i]);
			ptr[i] = blocks[i].length;
			ptr[i] = movePointer(sortedBlocks[i], addAll[i], max, ptr[i]);
		}
		
		
		for (int IT = 0; IT < q; IT++) {
			int type = in.nextInt();
			int from = in.nextInt() - 1, to = in.nextInt() - 1;
			if (type == 1) {
				int add = in.nextInt();
				
				for (int i = 0; i < COUNT; i++) {
					int l = i * SQROOT, r = Math.min(l + SQROOT, n) - 1;
					
					if (from <= l && r <= to) {
						addAll[i] = Math.min(max, addAll[i] + add);
						ptr[i] = movePointer(sortedBlocks[i], addAll[i], max, ptr[i]);
						continue;
					}
					
					int left = Math.max(l, from), right = Math.min(r, to);
					if (left <= right) {
						
						for (int j = 0; j < SQROOT; j++) {
							blocks[i][j] = Math.min(blocks[i][j] + addAll[i], max);
						}
						addAll[i] = 0;
						for (int j = left; j <= right; j++) {
							blocks[i][j - l] = Math.min(blocks[i][j - l] + add, max);
						}
						
						rebuildBlock(blocks[i], sortedBlocks[i], prefixSum[i]);
						ptr[i] = movePointer(blocks[i], 0, max, ptr[i]);
					}
				}
				
			} else {
				
				long ans = 0;
				
				for (int i = 0; i < COUNT; i++) {
					int l = i * SQROOT, r = Math.min(l + SQROOT, n) - 1;
					
					if (from <= l && r <= to) {
						int p = ptr[i];
						ans += (long) (blocks[i].length - p) * max;
						if (p > 0) {
							ans += prefixSum[i][p - 1] + (long) addAll[i] * p;
						}
						continue;
					}
					
					int left = Math.max(l, from), right = Math.min(r, to);
					if (left <= right) {
						for (int j = 0; j < SQROOT; j++) {
							blocks[i][j] = Math.min(blocks[i][j] + addAll[i], max);
							sortedBlocks[i][j] = Math.min(sortedBlocks[i][j] + addAll[i], max);
							prefixSum[i][j] += (long) (j + 1) * addAll[i];
						}
						addAll[i] = 0;
						
						ptr[i] = movePointer(blocks[i], 0, max, ptr[i]);
						
						for (int j = left; j <= right; j++) {
							ans += blocks[i][j - l];
						}
					}
				}
				
				out.println(ans);
			}
		}
	}

	private void rebuildBlock(int[] a, int[] sorted, long[] p) {
		System.arraycopy(a, 0, sorted, 0, a.length);
		doThePrefixSum(sorted, p);
	}

	private int movePointer(int[] a, int add, int max, int ptr) {
		while (ptr > 0 && a[ptr - 1] + add >= max) {
			ptr--;
		}
		return ptr;
	}

	private void doThePrefixSum(int[] a, long[] p) {
		p[0] = a[0];
		for (int i = 1; i < a.length; i++) {
			p[i] = p[i - 1] + a[i];
		}
	}

	void run() {
		try {
			in = new FastScanner("water.in");
			out = new PrintWriter("water.out");
			solve();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String file) {
			try {
				br = new BufferedReader(new FileReader(file));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

	public static void main(String[] args) {
		new water_av_sqrt().run();
	}
}
