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.util.*;
import java.io.*;
import java.awt.Point;
import java.math.BigInteger;

public class e535 {

	public static void main(String[] args) throws Exception {
		FastIO sc = new FastIO(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		SegmentTree tree = new SegmentTree(N);
		for(int i = 0; i < N; i++) {
			int x = sc.nextInt();
			tree.update(1, 0, N-1, i, i, x);
		}
		PriorityQueue<IntervalEvent> pq = new PriorityQueue<IntervalEvent>();
		for(int i = 0; i <M; i++) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			pq.add(new IntervalEvent(a, b, a, true, i));
			pq.add(new IntervalEvent(a, b, b, false, i));
		}
		long ans = 0;
		Integer[] arr = new Integer[0];
		HashSet<Integer> indices = new HashSet<Integer>();
		
		for(int i = 0; i < N; i++) {
			while(!pq.isEmpty() && pq.peek().time == i && pq.peek().starter) {
				IntervalEvent ie = pq.poll();
				tree.update(1, 0, N-1, ie.a, ie.b, -1);
				indices.add(ie.index);
			}
			
			if(tree.queryMax(1, 0, N-1, 0, N-1)-tree.queryMin(1, 0, N-1, 0, N-1) > ans) {
				ans = tree.queryMax(1, 0, N-1, 0, N-1)-tree.queryMin(1, 0, N-1, 0, N-1);
				arr = indices.toArray(new Integer[0]);
			}
			//System.out.println(Arrays.toString(tree.min));
			//System.out.println(Arrays.toString(tree.max));
			
			while(!pq.isEmpty() && pq.peek().time == i && !pq.peek().starter) {
				IntervalEvent ie = pq.poll();
				tree.update(1, 0, N-1, ie.a, ie.b, 1);
				indices.remove(ie.index);
			}
		}
		
		pw.println(ans);
		pw.println(arr.length);
		
		for(int i = 0; i < arr.length; i++) {
			pw.print(arr[i]+1);
			if(i != arr.length-1) pw.print(" ");
		}
		pw.println();
		pw.close();
		
	}
	
	static class IntervalEvent implements Comparable<IntervalEvent> {
		
		int a, b;
		int index;
		int time;
		
		boolean starter;
		
		public IntervalEvent(int a, int b, int time, boolean starter, int index) {
			this.a = a;
			this.b = b;
			this.time = time;
			this.starter = starter;
			this.index = index;
		}
		
		public int compareTo(IntervalEvent e) {
			if(time == e.time) {
				if(starter && !e.starter) return -1;
				if(!starter && e.starter) return 1;
				return 0;
			}
			return Integer.compare(time, e.time);
		}
		
	}
	
	static class SegmentTree {
		
		long[] lazy;
		long[] min;
		long[] max;
		
		public SegmentTree(int n) {
			lazy = new long[n*4];
			min = new long[n*4];
			max = new long[n*4];
		}
		
		public long queryMax(int vert, int i, int j, int l, int r) {
			if(!intersects(i, j, l, r)) {
				return Integer.MIN_VALUE;
			}
			
			if(inside(i, j, l, r)) {
				return max[vert]+lazy[vert];
			}
			
			lazy[vert*2] += lazy[vert];
			lazy[vert*2+1] += lazy[vert];
			lazy[vert] = 0;
			
			int mid = (i+j)/2;
			long ret = Math.max(queryMax(vert*2, i, mid, l, r), queryMax(vert*2+1, mid+1, j, l, r));
			
			min[vert] = Math.min(min[vert*2]+lazy[vert*2], min[vert*2+1]+lazy[vert*2+1]);
			max[vert] = Math.max(max[vert*2]+lazy[vert*2], max[vert*2+1]+lazy[vert*2+1]);
			
			return ret;
		}
		
		public long queryMin(int vert, int i, int j, int l, int r) {
			if(!intersects(i, j, l, r)) {
				return Integer.MAX_VALUE;
			}
			
			if(inside(i, j, l, r)) {
				return min[vert]+lazy[vert];
			}
			
			lazy[vert*2] += lazy[vert];
			lazy[vert*2+1] += lazy[vert];
			lazy[vert] = 0;
			
			int mid = (i+j)/2;
			long ret = Math.min(queryMin(vert*2, i, mid, l, r), queryMin(vert*2+1, mid+1, j, l, r));
			
			min[vert] = Math.min(min[vert*2]+lazy[vert*2], min[vert*2+1]+lazy[vert*2+1]);
			max[vert] = Math.max(max[vert*2]+lazy[vert*2], max[vert*2+1]+lazy[vert*2+1]);
			
			return ret;
		}
		
		public void update(int vert, int i, int j, int l, int r, long a) {
			if(!intersects(i, j, l, r)) {
				return;
			}
			
			if(inside(i, j, l, r)) {
				lazy[vert] += a;
				return;
			}
			
			lazy[vert*2] += lazy[vert];
			lazy[vert*2+1] += lazy[vert];
			lazy[vert] = 0;
			
			int mid = (i+j)/2;
			
			update(vert*2, i, mid, l, r, a);
			update(vert*2+1, mid+1, j, l, r, a);
			
			min[vert] = Math.min(min[vert*2]+lazy[vert*2], min[vert*2+1]+lazy[vert*2+1]);
			max[vert] = Math.max(max[vert*2]+lazy[vert*2], max[vert*2+1]+lazy[vert*2+1]);
		}
		
	}
	
	static boolean inside(int inI, int inJ, int left, int right) {
		return (left <= inI) && (inJ <= right);
	}
	
	static boolean intersects(int i, int j, int l, int r) {
		return (j >= l) && (i <= r);
	}

	static class FastIO {

		//Is your Fast I/O being bad?

		InputStream dis;
		byte[] buffer = new byte[1 << 17];
		int pointer = 0;

		public FastIO(String fileName) throws Exception {
			dis = new FileInputStream(fileName);
		}

		public FastIO(InputStream is) throws Exception {
			dis = is;
		}

		int nextInt() throws Exception {
			int ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		long nextLong() throws Exception {
			long ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		byte nextByte() throws Exception {
			if (pointer == buffer.length) {
				dis.read(buffer, 0, buffer.length);
				pointer = 0;
			}
			return buffer[pointer++];
		}

		String next() throws Exception {
			StringBuffer ret = new StringBuffer();

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			while (b > ' ') {
				ret.appendCodePoint(b);
				b = nextByte();
			}

			return ret.toString();
		}

	}
}