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.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

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

  static class E2ArrayAndSegmentsHardVersion {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      int n = in.readInt(), m = in.readInt();
      long[] array = new long[n];
      int[][] seg = new int[m][];

      List<Integer[]>[] st = new List[n];
      List<Integer[]>[] fn = new List[n];
      for (int i = 0; i < n; ++i) {
        st[i] = new ArrayList<>();
        fn[i] = new ArrayList<>();
      }

      for (int i = 0; i < n; ++i) array[i] = in.readInt();

      SumIntervalTree tree =
          new SumIntervalTree(array.clone()) {

            protected long joinValue(long left, long right) {
              return Math.min(left, right);
            }

            protected long neutralValue() {
              return Long.MAX_VALUE;
            }

            protected long emptySegmentResult() {
              return Long.MAX_VALUE;
            }

            protected long accumulate(long value, long delta, int length) {
              return value + delta;
            }
          };

      for (int i = 0; i < m; ++i) {
        int[] item = new int[] {in.readInt() - 1, in.readInt() - 1};
        st[item[0]].add(new Integer[] {item[0], item[1]});
        fn[item[1]].add(new Integer[] {item[0], item[1]});
        seg[i] = item;
        tree.update(item[0], item[1], -1);
      }

      long ans = -1;
      int idx = 0;
      for (int i = 0; i < n; ++i) {

        for (Integer[] q : st[i]) {
          tree.update(q[0].intValue(), q[1].intValue(), 1);
        }
        if (array[i] - tree.query(0, n - 1) > ans) {
          idx = i;
          ans = array[i] - tree.query(0, n - 1);
        }
        for (Integer[] q : fn[i]) {
          tree.update(q[0].intValue(), q[1].intValue(), -1);
        }
      }

      out.printLine(ans);
      List<Integer> lst = new ArrayList<>();
      for (int i = 0; i < m; ++i)
        if (idx < seg[i][0] || idx > seg[i][1]) {
          lst.add(i + 1);
        }
      out.printLine(lst.size());
      if (!lst.isEmpty()) out.printLine(lst.toArray());
    }
  }

  static class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
      for (int i = 0; i < objects.length; i++) {
        if (i != 0) {
          writer.print(' ');
        }
        writer.print(objects[i]);
      }
    }

    public void printLine(Object... objects) {
      print(objects);
      writer.println();
    }

    public void close() {
      writer.close();
    }

    public void printLine(long i) {
      writer.println(i);
    }

    public void printLine(int i) {
      writer.println(i);
    }
  }

  static class SumIntervalTree extends LongIntervalTree {
    private final long[] array;

    public SumIntervalTree(int size) {
      super(size);
      array = null;
    }

    public SumIntervalTree(long[] array) {
      super(array.length, false);
      this.array = array;
      init();
    }

    protected long initValue(int index) {
      if (array == null) {
        return 0;
      }
      return array[index];
    }

    protected long joinValue(long left, long right) {
      return left + right;
    }

    protected long joinDelta(long was, long delta) {
      return was + delta;
    }

    protected long accumulate(long value, long delta, int length) {
      return value + delta * length;
    }

    protected long neutralValue() {
      return 0;
    }

    protected long neutralDelta() {
      return 0;
    }
  }

  abstract static class IntervalTree {
    protected int size;

    protected IntervalTree(int size) {
      this(size, true);
    }

    public IntervalTree(int size, boolean shouldInit) {
      this.size = size;
      int nodeCount = Math.max(1, Integer.highestOneBit(size) << 2);
      initData(size, nodeCount);
      if (shouldInit) {
        init();
      }
    }

    protected abstract void initData(int size, int nodeCount);

    protected abstract void initAfter(int root, int left, int right, int middle);

    protected abstract void initBefore(int root, int left, int right, int middle);

    protected abstract void initLeaf(int root, int index);

    protected abstract void updatePostProcess(
        int root, int left, int right, int from, int to, long delta, int middle);

    protected abstract void updatePreProcess(
        int root, int left, int right, int from, int to, long delta, int middle);

    protected abstract void updateFull(int root, int left, int right, int from, int to, long delta);

    protected abstract long queryPostProcess(
        int root,
        int left,
        int right,
        int from,
        int to,
        int middle,
        long leftResult,
        long rightResult);

    protected abstract void queryPreProcess(
        int root, int left, int right, int from, int to, int middle);

    protected abstract long queryFull(int root, int left, int right, int from, int to);

    protected abstract long emptySegmentResult();

    public void init() {
      if (size == 0) {
        return;
      }
      init(0, 0, size - 1);
    }

    private void init(int root, int left, int right) {
      if (left == right) {
        initLeaf(root, left);
      } else {
        int middle = (left + right) >> 1;
        initBefore(root, left, right, middle);
        init(2 * root + 1, left, middle);
        init(2 * root + 2, middle + 1, right);
        initAfter(root, left, right, middle);
      }
    }

    public void update(int from, int to, long delta) {
      update(0, 0, size - 1, from, to, delta);
    }

    protected void update(int root, int left, int right, int from, int to, long delta) {
      if (left > to || right < from) {
        return;
      }
      if (left >= from && right <= to) {
        updateFull(root, left, right, from, to, delta);
        return;
      }
      int middle = (left + right) >> 1;
      updatePreProcess(root, left, right, from, to, delta, middle);
      update(2 * root + 1, left, middle, from, to, delta);
      update(2 * root + 2, middle + 1, right, from, to, delta);
      updatePostProcess(root, left, right, from, to, delta, middle);
    }

    public long query(int from, int to) {
      return query(0, 0, size - 1, from, to);
    }

    protected long query(int root, int left, int right, int from, int to) {
      if (left > to || right < from) {
        return emptySegmentResult();
      }
      if (left >= from && right <= to) {
        return queryFull(root, left, right, from, to);
      }
      int middle = (left + right) >> 1;
      queryPreProcess(root, left, right, from, to, middle);
      long leftResult = query(2 * root + 1, left, middle, from, to);
      long rightResult = query(2 * root + 2, middle + 1, right, from, to);
      return queryPostProcess(root, left, right, from, to, middle, leftResult, rightResult);
    }
  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1) {
        throw new InputMismatchException();
      }
      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (numChars <= 0) {
          return -1;
        }
      }
      return buf[curChar++];
    }

    public int readInt() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) {
        return filter.isSpaceChar(c);
      }
      return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }

  abstract static class LongIntervalTree extends IntervalTree {
    protected long[] value;
    protected long[] delta;

    protected LongIntervalTree(int size) {
      this(size, true);
    }

    public LongIntervalTree(int size, boolean shouldInit) {
      super(size, shouldInit);
    }

    protected void initData(int size, int nodeCount) {
      value = new long[nodeCount];
      delta = new long[nodeCount];
    }

    protected abstract long joinValue(long left, long right);

    protected abstract long joinDelta(long was, long delta);

    protected abstract long accumulate(long value, long delta, int length);

    protected abstract long neutralValue();

    protected abstract long neutralDelta();

    protected long initValue(int index) {
      return neutralValue();
    }

    protected void initAfter(int root, int left, int right, int middle) {
      value[root] = joinValue(value[2 * root + 1], value[2 * root + 2]);
      delta[root] = neutralDelta();
    }

    protected void initBefore(int root, int left, int right, int middle) {}

    protected void initLeaf(int root, int index) {
      value[root] = initValue(index);
      delta[root] = neutralDelta();
    }

    protected void updatePostProcess(
        int root, int left, int right, int from, int to, long delta, int middle) {
      value[root] = joinValue(value[2 * root + 1], value[2 * root + 2]);
    }

    protected void updatePreProcess(
        int root, int left, int right, int from, int to, long delta, int middle) {
      pushDown(root, left, middle, right);
    }

    protected void pushDown(int root, int left, int middle, int right) {
      value[2 * root + 1] = accumulate(value[2 * root + 1], delta[root], middle - left + 1);
      value[2 * root + 2] = accumulate(value[2 * root + 2], delta[root], right - middle);
      delta[2 * root + 1] = joinDelta(delta[2 * root + 1], delta[root]);
      delta[2 * root + 2] = joinDelta(delta[2 * root + 2], delta[root]);
      delta[root] = neutralDelta();
    }

    protected void updateFull(int root, int left, int right, int from, int to, long delta) {
      value[root] = accumulate(value[root], delta, right - left + 1);
      this.delta[root] = joinDelta(this.delta[root], delta);
    }

    protected long queryPostProcess(
        int root,
        int left,
        int right,
        int from,
        int to,
        int middle,
        long leftResult,
        long rightResult) {
      return joinValue(leftResult, rightResult);
    }

    protected void queryPreProcess(int root, int left, int right, int from, int to, int middle) {
      pushDown(root, left, middle, right);
    }

    protected long queryFull(int root, int left, int right, int from, int to) {
      return value[root];
    }

    protected long emptySegmentResult() {
      return neutralValue();
    }
  }
}
