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.
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.OptionalLong;
import java.nio.charset.Charset;
import java.util.StringTokenizer;
import java.io.OutputStreamWriter;
import java.util.NoSuchElementException;
import java.io.OutputStream;
import java.util.stream.LongStream;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Objects;
import java.util.List;
import java.io.Writer;
import java.security.AccessControlException;
import java.io.BufferedReader;
import java.util.regex.Pattern;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        LightWriter out = new LightWriter(outputStream);
        E2ArrayAndSegmentsHardVersion solver = new E2ArrayAndSegmentsHardVersion();
        solver.solve(1, in, out);
        out.close();
    }

    static class E2ArrayAndSegmentsHardVersion {
        public void solve(int testNumber, LightScanner in, LightWriter out) {
            Debug.autoEnable();
            int n = in.ints(), m = in.ints();
            long[] a = in.longs(n);

            if (m == 0) {
                out.ans(IntMath.max(a) - IntMath.min(a)).ln()
                        .ans(0).ln();
                return;
            } else if (n == 1) {
                out.ans(0).ln()
                        .ans(0).ln();
                return;
            }

            Vec3i[] segs = new Vec3i[m];
            for (int i = 0; i < m; i++) {
                segs[i] = new Vec3i(in.ints() - 1, in.ints() - 1, i + 1);
            }

            MergeSort.sort(segs, Comparator.comparing(seg -> seg.y));
            long[] lb = a.clone();
            long t = Integer.MAX_VALUE;
            long[] minLeft = new long[n];
            minLeft[0] = t;
            int c = 0;
            for (int i = 1; i < n; i++) {
                t = Math.min(t, a[i - 1]);
                while (c < m && segs[c].y < i) {
                    for (int j = segs[c].x; j <= segs[c].y; j++) {
                        lb[j]--;
                        t = Math.min(t, lb[j]);
                    }
                    c++;
                }
                minLeft[i] = t;
            }


            MergeSort.sort(segs, Comparator.comparing(seg -> -seg.x));
            lb = a.clone();
            t = Integer.MAX_VALUE;
            long[] minRight = new long[n];
            minRight[n - 1] = t;
            c = 0;
            for (int i = n - 2; i >= 0; i--) {
                t = Math.min(t, a[i + 1]);
                while (c < m && segs[c].x > i) {
                    for (int j = segs[c].x; j <= segs[c].y; j++) {
                        lb[j]--;
                        t = Math.min(t, lb[j]);
                    }
                    c++;
                }
                minRight[i] = t;
            }

            //System.out.println(Arrays.toString(minLeft));
            //System.out.println(Arrays.toString(minRight));

            long ans = -1;
            long ansi = -1;
            for (int i = 0; i < n; i++) {
                long ta = a[i] - Math.min(minLeft[i], minRight[i]);
                if (ta > ans) {
                    ans = ta;
                    ansi = i;
                }
            }

            //System.out.println("ANIS="+ansi);

            List<Vec3i> res = new ArrayList<>();
            for (Vec3i seg : segs) {
                if (seg.y < ansi || ansi < seg.x) {
                    res.add(seg);
                }
            }
            out.ans(ans).ln().ans(res.size()).ln();
            for (Vec3i seg : res) {
                out.ans(seg.z);
            }
            out.ln();
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

        public long longs() {
            return Long.parseLong(string());
        }

        public long[] longs(int length) {
            return IntStream.range(0, length).mapToLong(x -> longs()).toArray();
        }

    }

    static class MergeSort {
        private static final int INSERTIONSORT_THRESHOLD = 7;

        private MergeSort() {
        }

        static <T> void sort(T[] src, T[] dest, int low, int high, int off, Comparator<? super T> comparator) {
            int length = high - low;
            if (length < INSERTIONSORT_THRESHOLD) {
                InsertionSort.sort(dest, low, high, comparator);
                return;
            }
            int destLow = low;
            int destHigh = high;
            low += off;
            high += off;
            int mid = (low + high) / 2;
            sort(dest, src, low, mid, -off, comparator);
            sort(dest, src, mid, high, -off, comparator);
            if (comparator.compare(src[mid - 1], src[mid]) <= 0) {
                System.arraycopy(src, low, dest, destLow, length);
                return;
            }
            for (int i = destLow, p = low, q = mid; i < destHigh; i++) {
                if (q >= high || p < mid && comparator.compare(src[p], src[q]) <= 0) {
                    dest[i] = src[p++];
                } else {
                    dest[i] = src[q++];
                }
            }
        }

        public static <T> void sort(T[] a, Comparator<? super T> comparator) {
            sort(a.clone(), a, 0, a.length, 0, comparator);
        }

    }

    static class Debug {
        private static final String DEBUG_PROPERTY = "debug";
        private static final String DEBUG_CALL_PATTERN = "^.+\\.debug\\((.+)\\);.*$";
        private static Pattern debugRegex;
        private static boolean enabled = false;
        private static String src;

        public static void enable(String s) {
            enabled = true;
            src = s;
            if (debugRegex == null) {
                debugRegex = Pattern.compile(DEBUG_CALL_PATTERN);
            }
        }

        public static boolean autoEnable() {
            try {
                String s = System.getProperty(DEBUG_PROPERTY);
                if (s != null) {
                    enable(s);
                    return true;
                }
            } catch (AccessControlException ex) {
                src = null;
            }
            return false;
        }

    }

    static class Vec3i {
        public int x;
        public int y;
        public int z;

        public Vec3i(int x, int y, int z) {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Vec3i vec3i = (Vec3i) o;
            return x == vec3i.x &&
                    y == vec3i.y &&
                    z == vec3i.z;
        }

        public int hashCode() {
            return Objects.hash(x, y, z);
        }

        public String toString() {
            return "(" + x + ", " + y + ", " + z + ")";
        }

    }

    static class LightWriter implements AutoCloseable {
        private final Writer out;
        private boolean autoflush = false;
        private boolean breaked = true;

        public LightWriter(Writer out) {
            this.out = out;
        }

        public LightWriter(OutputStream out) {
            this(new BufferedWriter(new OutputStreamWriter(out, Charset.defaultCharset())));
        }

        public LightWriter print(char c) {
            try {
                out.write(c);
                breaked = false;
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
            return this;
        }

        public LightWriter print(String s) {
            try {
                out.write(s, 0, s.length());
                breaked = false;
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
            return this;
        }

        public LightWriter ans(String s) {
            if (!breaked) {
                print(' ');
            }
            return print(s);
        }

        public LightWriter ans(long l) {
            return ans(Long.toString(l));
        }

        public LightWriter ans(int i) {
            return ans(Integer.toString(i));
        }

        public LightWriter ln() {
            print(System.lineSeparator());
            breaked = true;
            if (autoflush) {
                try {
                    out.flush();
                } catch (IOException ex) {
                    throw new UncheckedIOException(ex);
                }
            }
            return this;
        }

        public void close() {
            try {
                out.close();
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
        }

    }

    static class InsertionSort {
        private InsertionSort() {
        }

        static <T> void sort(T[] a, int low, int high, Comparator<? super T> comparator) {
            for (int i = low; i < high; i++) {
                for (int j = i; j > low && comparator.compare(a[j - 1], a[j]) > 0; j--) {
                    T t = a[j];
                    a[j] = a[j - 1];
                    a[j - 1] = t;
                }
            }
        }

    }

    static final class IntMath {
        private IntMath() {
        }

        public static long min(long... v) {
            return Arrays.stream(v).min().orElseThrow(NoSuchElementException::new);
        }

        public static long max(long... v) {
            return Arrays.stream(v).max().orElseThrow(NoSuchElementException::new);
        }

    }
}

