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 ≤ 10^5, 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
4 1 


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.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
public class Main {

    public void sort(long b[]){
        Random rd = new Random();
        for(int i=1;i<b.length;++i){
            int c = rd.nextInt(i);
            long v = b[c];
            b[c] = b[i];
            b[i] = v;
        }
        Arrays.sort(b);
    }
    public void sort(int b[]){
        Random rd = new Random();
        for(int i = 1;i<b.length;++i){
            int c = rd.nextInt(i);
            int v = b[c];
            b[c]= b[i];
            b[i] = v;
        }
        Arrays.sort(b);
    }


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

        void solve(){

            int n = ni();
            int m =ni();

            int a[] = na(n);

            int ma = a[0];
            int mi =a[0];
            int res = 0;
            for(int i=1;i<n;++i){
                ma =Math.max(ma,a[i]);
                mi =Math.min(mi,a[i]);
            }
            res =ma-mi;

            int l[] =new int[m];
            int r[] =new int[m];

        TreeSet<Integer> st =new TreeSet<>();
        for(int i=0;i<m;++i){
            l[i] = ni()-1;
            r[i] = ni();
            st.add(l[i]);
            st.add(r[i]);
        }
        int sz =st.size();
        int seg[] = new int[m*2];
        int p  = 0;
        for(int u:st){
            seg[p++] = u;
        }
        int c[] = new int[n+1];
        int idx = -1;
        for(int i=0;i<p;++i){
            for(int j=0;j<m;++j){
                if(seg[i]>=l[j]&&seg[i]<r[j]) continue;
                c[l[j]]--;
                c[r[j]]++;
            }
            ma = -10000000;
            mi = 10000000;
            int s = 0;
            for(int j=0;j<n;++j){
                s += c[j];
                ma = Math.max(a[j]+s,ma);
                mi = Math.min(a[j]+s,mi);
            }
            if(ma-mi>res){
                res = ma-mi;
                idx = i;
            }
            for(int j=0;j<m;++j){
                if(seg[i]>=l[j]&&seg[i]<r[j]) continue;
                c[l[j]]++;
                c[r[j]]--;
            }
        }
        println(res);
        if(idx==-1){
            println(0);return;
        }

             int fk[] = new int[m];
             int mp = 0;

            for(int j=0;j<m;++j){
                if(seg[idx]>=l[j]&&seg[idx]<r[j]) continue;
                fk[mp++] = j+1;
            }
            println(mp);
            for(int j=0;j<mp;++j){
                print(fk[j]+" ");
            }






//         PriorityQueue<int[]> q= new PriorityQueue<>((x,y)->{return x[0]-y[0];});
//
//         q.offer(new int[]{0,0});
//         boolean inq[] = new boolean[n];
//         while(q.size()>0){
//             int c[]= q.poll();
//             for(int i=h[c[1]];i!=-1;i=ne[i]){
//                 if(!inq[to[i]]) {
//                     q.offer(new int[]{ wt[i], to[i]});
//                     inq[to[i]] = true;
//                 }
//             }
//         }





        }


       int err = 0;



    void go(int rt,int pt,int fa) {
        stk[rt] = pt;
        for(int i=h[rt];i!=-1;i=ne[i]) {
            if(to[i]==pt||to[i]==fa) continue;
            go(to[i],pt,rt);
        }
    }



    int ct = 0;
    void add(int u,int v,int w,int q){
        to[ct] = v;
        wt[ct] = w;
        qt[ct] = q;
        ne[ct] = h[u];
        h[u] = ct++;
//
//        to1[ct] = u;
//        wt1[ct] = w;
//        ne1[ct] = h1[v];
//        h1[v] = ct++;
    }
    int []h,ne,to,wt,qt,stk;


    long inv(long a, long MOD) {
        //return fpow(a, MOD-2, MOD);
        return a==1?1:(long )(MOD-MOD/a)*inv(MOD%a, MOD)%MOD;
    }


    void inverse(){
        int MAXN = 10000;
        long inv[] = new long[MAXN+1];
        inv[1] = 1; //注意初始化
        long mod = 1000000007;
        for (int i=2; i<=MAXN; ++i) {
            inv[i] = (mod - mod / i) * inv[(int) (mod % i)] % mod;
        }
    }



    // 计算某个特别大的组合数
    long C(long n,long m, long MOD) {
        if(m+m>n)m=n-m;
        long up=1,down=1;
        for(long i=0;i<m;i++)
        {
            up=up*(n-i)%MOD;
            down=down*(i+1)%MOD;
        }
        return up*inv(down, MOD)%MOD;
    }


    void solve2() {

            int n = ni();
            String s=  ns();
            int g[][] = new int[3][3];
            for(int i = 0;i<n;++i){
                char c = s.charAt(i);
                int idx = 0;
                if(c=='G'){
                    idx =1;
                }else if(c=='B'){
                    idx =2;
                }
                g[c][i%3]++;
            }







        }































//    int []h,to,ne,wt;

    long t1[];
    //    long t2[];
    void update(long[] t,int i,long v){
        for(;i<t.length;i+=(i&-i)){
            t[i] += v;
        }
    }
    long get(long[] t,int i){
        long s = 0;
        for(;i>0;i-=(i&-i)){
            s += t[i];
        }
        return s;
    }

    int equal_bigger(long t[],long v){
        int s=0,p=0;
        for(int i=Integer.numberOfTrailingZeros(Integer.highestOneBit(t.length));i>=0;--i) {
            if(p+(1<<i)< t.length && s + t[p+(1<<i)] < v){
                v -= t[p+(1<<i)];
                p |= 1<<i;
            }
        }
        return p+1;
    }


    long gcd(long a,long b){ return b==0?a: gcd(b,a%b);}
    InputStream is;PrintWriter out;
    void run() throws Exception {is = System.in;
      //  is = new FileInputStream("C:\\Users\\Luqi\\Downloads\\P1600_2.in");

        out = new PrintWriter(System.out);solve();out.flush();}
    private byte[] inbuf = new byte[2];
    public int lenbuf = 0, ptrbuf = 0;
    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {lenbuf = is.read(inbuf);} catch (IOException e) {throw new InputMismatchException();}
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];}
    private boolean isSpaceChar(int c) {return !(c >= 33 && c <= 126);}
    private int skip() {int b;while((b = readByte()) != -1 && isSpaceChar(b));return b;}
    private double nd() {return Double.parseDouble(ns());}
    private char nc() {return (char) skip();}
    private char ncc() {int b;while((b = readByte()) != -1 && !(b >= 32 && b <= 126));return (char)b;}
    private String ns() {int b = skip();StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);b = readByte(); }
        return sb.toString();}
    private char[] ns(int n) {char[] buf = new char[n];int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) { buf[p++] = (char) b;b = readByte(); }
        return n == p ? buf : Arrays.copyOf(buf, p);}
    private String nline() {int b = skip();StringBuilder sb = new StringBuilder();
        while (!isSpaceChar(b) || b == ' ') { sb.appendCodePoint(b);b = readByte(); }
        return sb.toString();}
    private char[][] nm(int n, int m) {char[][] a = new char[n][];for (int i = 0; i < n; i++) a[i] = ns(m);return a;}
    private int[] na(int n) {int[] a = new int[n];for (int i = 0; i < n; i++) a[i] = ni();return a;}
    private long[] nal(int n) { long[] a = new long[n];for (int i = 0; i < n; i++) a[i] = nl();return a;}
    private int ni() { int num = 0, b; boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')){};
        if (b == '-') { minus = true; b = readByte(); }
        while (true) {
            if (b >= '0' && b <= '9') num = (num << 3) + (num << 1) + (b - '0');
            else return minus ? -num : num;
            b = readByte();}}
    private long nl() { long num = 0; int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')){};
        if (b == '-') { minus = true; b = readByte(); }
        while (true) {
            if (b >= '0' && b <= '9')  num = num * 10 + (b - '0');
            else return minus ? -num : num;
            b = readByte();}}
    void print(Object obj){out.print(obj);}
    void println(Object obj){out.println(obj);}
    void println(){out.println();}
}