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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long mo = 998244353;
long long sx, sy, ex, ey, dx[6] = {0, 1, 0, -1, 0, 0},
                          dy[6] = {1, 0, -1, 0, 0, 0}, m, n, k,
                          dz[6]{0, 0, 0, 0, -1, 1}, sg;
long long p, no, v, ans, w;
int par[550000];
long long a[500005], b[400005], c[500006], d1[400006], l[500006], r[500006];
int lg[200005], mi2[50], mn[25][200005];
long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }
set<pair<long long, int> > se;
struct node {
  long long u, v, w;
};
vector<node> eg;
long long qu(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) {
      ans = ans % m * a % m;
    }
    b >>= 1;
    a = a % m * a % m;
  }
  return ans;
}
int su(int n) {
  if (n == 1 || n == 0) return 0;
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return 0;
  }
  return 1;
}
int fi(int a) {
  if (a == par[a])
    return a;
  else
    return par[a] = fi(par[a]);
}
map<int, long long> mp, mp1;
map<pair<long long, int>, int> mp2;
priority_queue<pair<long long, int> > que;
pair<long long, int> a1[400000], a2[400000];
int vis[400055], vis1[400055], vis2[400055];
char maze[505][505];
vector<int> g[400000], g1[400000];
vector<long long> ve, ve1;
int seg[100005 << 2], add[100005 << 2], mi[100005 << 2], ma[100005 << 2];
int ansma, ansmi;
int cmp1(pair<long long, int> a, pair<long long, int> b) {
  return a.second < b.second;
}
int cmp(node a, node b) { return a.w < b.w; }
void pushup(int rt) {
  mi[rt] = min(mi[rt << 1], mi[rt << 1 | 1]);
  ma[rt] = max(ma[rt << 1], ma[rt << 1 | 1]);
  seg[rt] = ma[rt] - mi[rt];
}
void cre(int rt, int l, int r) {
  add[rt] = 0;
  if (l == r) {
    mi[rt] = a[l];
    ma[rt] = a[l];
    return;
  }
  cre(rt << 1, l, ((l + r) >> 1));
  cre(rt << 1 | 1, ((l + r) >> 1) + 1, r);
  pushup(rt);
}
void pushdown(int rt) {
  if (add[rt]) {
    add[rt << 1] += add[rt];
    add[rt << 1 | 1] += add[rt];
    mi[rt << 1] += add[rt];
    mi[rt << 1 | 1] += add[rt];
    ma[rt << 1] += add[rt];
    ma[rt << 1 | 1] += add[rt];
    add[rt] = 0;
  }
}
void queryma(int rt, int l, int r) {
  int res = 0;
  if (l == r) {
    ansma = max(ansma, ma[rt]);
    return;
  }
  pushdown(rt);
  queryma(rt << 1, l, ((l + r) >> 1));
  queryma(rt << 1 | 1, ((l + r) >> 1) + 1, r);
  pushup(rt);
}
void querymi(int rt, int l, int r) {
  int res = 0;
  if (l == r) {
    ansmi = min(ansmi, mi[rt]);
    return;
  }
  pushdown(rt);
  querymi(rt << 1, l, ((l + r) >> 1));
  querymi(rt << 1 | 1, ((l + r) >> 1) + 1, r);
  pushup(rt);
}
void up(int rt, int l, int r, int L, int R, int w) {
  if (l >= L && r <= R) {
    mi[rt] += w;
    ma[rt] += w;
    add[rt] += w;
    return;
  }
  pushdown(rt);
  if (L <= ((l + r) >> 1)) up(rt << 1, l, ((l + r) >> 1), L, R, w);
  if (R > ((l + r) >> 1)) up(rt << 1 | 1, ((l + r) >> 1) + 1, r, L, R, w);
  pushup(rt);
}
int main() {
  int t, p2, p3;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s, ss, sss;
  long long l, r, n1, u, l1, r1;
  int tot = 1;
  char ch;
  while (cin >> n >> m) {
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    cre(1, 1, n);
    for (int i = 1; i <= m; i++) {
      cin >> a1[i].first >> a1[i].second;
      g[a1[i].second].push_back(i);
      g1[a1[i].first].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < g[i - 1].size(); j++) {
        up(1, 1, n, a1[g[i - 1][j]].first, a1[g[i - 1][j]].second, 1);
      }
      for (int j = 0; j < g1[i].size(); j++) {
        up(1, 1, n, a1[g1[i][j]].first, a1[g1[i][j]].second, -1);
      }
      if (ma[1] - mi[1] > ans) {
        ans = seg[1];
        sg = i;
      }
    }
    for (int i = 1; i <= m; i++) {
      if (a1[i].first <= sg && a1[i].second >= sg) ve.push_back(i);
    }
    cout << ans << endl;
    cout << ve.size() << endl;
    for (int i = 0; i < ve.size(); i++) {
      cout << ve[i] << " ";
    }
    cout << endl;
  }
}