import java.util.*; import java.io.*; public class Main { public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); int n = Integer.parseInt(first[0]); int q = Integer.parseInt(first[1]); BinaryIndexedTree bit = new BinaryIndexedTree(n + 1); long[] arr = new long[n + 2]; String[] second = br.readLine().split(" ", n); int prev = Integer.parseInt(second[0]); for (int i = 1; i < n; i++) { int x = Integer.parseInt(second[i]); arr[i] = x - prev; prev = x; if (arr[i] != 0) { bit.add(i, 1); } } arr[n] = prev; bit.add(n, 1); StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { String[] line = br.readLine().split(" "); int type = Integer.parseInt(line[0]); int left = Integer.parseInt(line[1]); int right = Integer.parseInt(line[2]); if (type == 1) { int x = Integer.parseInt(line[3]); if (arr[left - 1] == 0 && left > 1) { bit.add(left - 1, 1); } arr[left - 1] -= x; if (arr[left - 1] == 0 && left > 1) { bit.add(left - 1, -1); } if (arr[right] == 0) { bit.add(right, 1); } arr[right] += x; if (arr[right] == 0) { bit.add(right, -1); } } else { sb.append(bit.getSum(left, right)).append("\n"); } } System.out.print(sb); } } class BinaryIndexedTree { int size; int[] tree; public BinaryIndexedTree(int size) { this.size = size; tree = new int[size]; } public void add(int idx, int value) { int mask = 1; while (idx < size) { if ((idx & mask) != 0) { tree[idx] += value; idx += mask; } mask <<= 1; } } public int getSum(int from, int to) { return getSum(to) - getSum(from - 1); } public int getSum(int x) { int mask = 1; int ans = 0; while (x > 0) { if ((x & mask) != 0) { ans += tree[x]; x -= mask; } mask <<= 1; } return ans; } }