Problem: The only difference between easy and hard versions is a number of elements in the array.

You are given an array a consisting of n integers. The value of the i-th element of the array is a_i.

You are also given a set of m segments. The j-th segment is [l_j; r_j], where 1 ≤ l_j ≤ r_j ≤ n.

You can choose some subset of the given set of segments and decrease values on each of the chosen segments by one (independently). For example, if the initial array a = [0, 0, 0, 0, 0] and the given segments are [1; 3] and [2; 4] then you can choose both of them and the array will become b = [-1, -2, -2, -1, 0].

You have to choose some subset of the given segments (each segment can be chosen at most once) in such a way that if you apply this subset of segments to the array a and obtain the array b then the value max_{i=1}^{n}b_i - min_{i=1}^{n}b_i will be maximum possible.

Note that you can choose the empty set.

If there are multiple answers, you can print any.

If you are Python programmer, consider using PyPy instead of Python when you submit your code.

Input

The first line of the input contains two integers n and m (1 ≤ n ≤ 300, 0 ≤ m ≤ 300) — the length of the array a and the number of segments, respectively.

The second line of the input contains n integers a_1, a_2, ..., a_n (-10^6 ≤ a_i ≤ 10^6), where a_i is the value of the i-th element of the array a.

The next m lines are contain two integers each. The j-th of them contains two integers l_j and r_j (1 ≤ l_j ≤ r_j ≤ n), where l_j and r_j are the ends of the j-th segment.

Output

In the first line of the output print one integer d — the maximum possible value max_{i=1}^{n}b_i - min_{i=1}^{n}b_i if b is the array obtained by applying some subset of the given segments to the array a.

In the second line of the output print one integer q (0 ≤ q ≤ m) — the number of segments you apply.

In the third line print q distinct integers c_1, c_2, ..., c_q in any order (1 ≤ c_k ≤ m) — indices of segments you apply to the array a in such a way that the value max_{i=1}^{n}b_i - min_{i=1}^{n}b_i of the obtained array b is maximum possible.

If there are multiple answers, you can print any.

Examples

Input


5 4
2 -2 3 1 2
1 3
4 5
2 5
1 3


Output


6
2
1 4 


Input


5 4
2 -2 3 1 4
3 5
3 4
2 4
2 5


Output


7
2
3 2 


Input


1 0
1000000


Output


0
0

Note

In the first example the obtained array b will be [0, -4, 1, 1, 2] so the answer is 6.

In the second example the obtained array b will be [2, -3, 1, -1, 4] so the answer is 7.

In the third example you cannot do anything so the answer is 0.

Solution (in JAVA):

Solution:
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main {
    static final long MOD = 1_000_000_007, INF = 1_000_000_000_000_000_000L;
    static final int INf = 1_000_000_000;
    static FastReader reader;
    static PrintWriter writer;
    public static void main(String[] args) {
        Thread t = new Thread(null, new O(), "Integer.MAX_VALUE", 100000000);
        t.start();
    }
    static class O implements Runnable {
        public void run() {
            try {
                magic();
            }
            catch (Exception e) {
                e.printStackTrace();
                System.exit(1);
            }
        }
    }
    static class FastReader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public FastReader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public FastReader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[1000000];
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10);
            if (neg) return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1) buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead) fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null) return;
            din.close();
        }
    }
    //variables here
    static int n,m,start[], end[], arr[],lazy[], tree[];
    static ArrayList<Integer> ends_at[], starts_at[];
    static void magic() throws IOException{
        reader = new FastReader();
        writer = new PrintWriter(System.out, true);
        n = reader.nextInt();
        int sz = (int)pow(2, ceil(log(n)/log(2))+1);
        tree = new int[sz];
        lazy = new int[sz];
        m = reader.nextInt();
        arr = new int[n];
        start = new int[m];
        end = new int[m];
        starts_at = new ArrayList[n];
        ends_at = new ArrayList[n];
        for(int i=0;i<n;++i) {
            starts_at[i] = new ArrayList<>();
            ends_at[i] = new ArrayList<>();
            arr[i] = reader.nextInt();
        }
        for(int i=0;i<m;++i) {
            int l = reader.nextInt(), r = reader.nextInt();
            --l;--r;
            start[i] = l;
            end[i] = r;
            starts_at[l].add(r);
            ends_at[r].add(l);
        }
        build(1,0,n-1);
        int max = Integer.MIN_VALUE, at = -1;
        for(int i=0;i<n;++i) {
            for(int e : starts_at[i]) {
                rangeUpdate(i, e, -1);
            }
            int ispe = query(0, n-1) - query(i,i);
            if(max<ispe) {
                max = ispe;
                at = i;
            }
            for(int e : ends_at[i]) {
                rangeUpdate(e, i, 1);
            }
        }
        //writer.println("at : "+at);
        writer.println(max);
        ArrayList<Integer> ans_list = new ArrayList<>();
        for(int i=0;i<m;++i) {
            if(start[i]<=at && at<=end[i]) {
                ans_list.add((i+1));
            }
        }
        writer.println(ans_list.size());
        for(int e : ans_list) {
            writer.print(e+" ");
        }
        writer.println();
    }
    static void build(int treein, int low, int high) {
        if(low==high) {
            tree[treein] = arr[low];
            return;
        }
        int mid = (low+high)>>1;
        build(2*treein, low, mid);
        build(2*treein+1, mid+1, high);
        tree[treein] = max(tree[2*treein], tree[2*treein+1]);
    }
    static void rangeUpdate(int l,int r,int val)
    {
        rangeUpdate(1,0,n-1,l,r,val);
    }
    static int query(int l,int r)
    {
        return query(1,0,n-1,l,r);
    }
    static void rangeUpdate(int treein,int low,int high,int l,int r,int val)
    {
        if(lazy[treein]!=0)
        {
            tree[treein]+=lazy[treein];
            if(low!=high)
            {
                lazy[2*treein]+=lazy[treein];
                lazy[2*treein+1]+=lazy[treein];
            }
            lazy[treein] = 0;
        }
        if(l<=low && high<=r)
        {
            tree[treein]+=val;
            if(low!=high)
            {
                lazy[2*treein]+=val;
                lazy[2*treein+1]+=val;
            }
            return;
        }
        if(low>r || high<l)
            return;
        int mid = (low+high)>>1;
        rangeUpdate(2*treein,low,mid,l,r,val);
        rangeUpdate(2*treein+1,mid+1,high,l,r,val);
        tree[treein] = max(tree[2*treein],tree[2*treein+1]);
    }
    static int query(int treein,int low,int high,int l,int r)
    {
        if(lazy[treein]!=0)
        {
            tree[treein]+=lazy[treein];
            if(low!=high)
            {
                lazy[2*treein]+=lazy[treein];
                lazy[2*treein+1]+=lazy[treein];
            }
            lazy[treein] = 0;
        }
        if(l<=low && high<=r)
            return tree[treein];
        if(low>r || high<l)
            return Integer.MIN_VALUE;
        int mid = (low+high)>>1;
        return max(query(2*treein+1,mid+1,high,l,r),query(2*treein,low,mid,l,r));
    }

}