#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 (seg[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;
  }
}
