import java.util.Scanner;// 注意类名必须为 Main, 不要有任何 package xxx 信息public class Main { // 给出一个长度为n的数组a,下标从1开始,q次询问,每次询问给两个区间,先让第一个区间的元素x2, // 再让第二个区间的元素x2,输出操作后数组目标总和 public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int q = in.nextInt(); int[] nn = new int[n + 1]; for (int i = 1; i nn[i] = in.nextInt(); nn[i] += nn[i - 1] ; //System.out.print(nn[i]+" "); } //System.out.println("??"); while (q > 0) { q--; int l1 = in.nextInt(); int r1 = in.nextInt(); int l2 = in.nextInt(); int r2 = in.nextInt(); if ((l1 >= l2 && l1 = l2 && r1 = l1 && r1 = l1 && r2 int left = Math.min(l1, l2); int right = Math.max(r1, r2); int ll = Math.max(l1, l2); int rr = Math.min(r1, r2); int res = nn[left - 1] + nn[n] - nn[right] + (nn[ll - 1] - nn[left - 1]) * 2 + (nn[right] - nn[rr]) * 2 + (nn[rr] - nn[ll - 1]) * 4; System.out.println(res); } else { if (l1 > l2) { int tl = l1; int tr = r1; l1 = l2; r1 = r2; l2 = tl; r2 = tr; } int res = nn[l1 - 1] + (nn[r1] - nn[l1 - 1]) * 2 + nn[l2 - 1] - nn[r1] + (nn[r2] - nn[l2 - 1]) * 2 + nn[n] - nn[r2]; System.out.println(res); } } }}