{ NOTE: it is recommended to use this even if you don't understand the following code }

const
    MAXN = 200001;
    MAXQ = 200001;

var
    N, Q, i, j : LongInt;
    V          : Array[1..MAXN] of LongInt;
    queries    : Array[1..MAXQ] of Array[0..1] of LongInt;
    cost       : Array[1..MAXQ] of LongInt;

begin
{
    uncomment the two following lines if you want to read/write from files
    assign(input,  'input.txt');  reset(input);
    assign(output, 'output.txt'); rewrite(output);
}

    ReadLn(N, Q);

    for i:=1 to N do
        Read(V[i]);
    ReadLn();

    for j:=1 to Q do begin
        for i:=0 to 2-1 do
            Read(queries[j][i]);
        ReadLn();
    end;

    for i := 1 to MAXQ do cost[i] := 0;

    { INSERT YOUR CODE HERE }


    for i:=1 to Q do
        WriteLn(cost[i]);

end.
