#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int n, m, a[100005], l[303], r[303];
int seg[606], ans = 0;
vector<int> A, cp;
struct Node {
  int l, r, maxn, lazy;
} t[100005 * 4];
void build(int idx, int l, int r) {
  t[idx].l = l, t[idx].r = r;
  if (l == r) {
    t[idx].maxn = a[l], t[idx].lazy = 0;
    return;
  }
  int mid = (l + r) >> 1;
  build(idx << 1, l, mid), build(idx << 1 | 1, mid + 1, r);
  t[idx].maxn =
      (t[idx << 1].maxn > t[idx << 1 | 1].maxn ? t[idx << 1].maxn
                                               : t[idx << 1 | 1].maxn);
}
void pushdown(int idx) {
  if (t[idx].lazy && t[idx].l != t[idx].r) {
    int lz = t[idx].lazy;
    t[idx].lazy = 0;
    t[idx << 1].lazy += lz, t[idx << 1 | 1].lazy += lz;
    t[idx << 1].maxn += lz, t[idx << 1 | 1].maxn += lz;
  }
}
void add(int idx, int l, int r, int w) {
  if (l <= t[idx].l && r >= t[idx].r) {
    t[idx].maxn += w, t[idx].lazy += w;
    return;
  }
  pushdown(idx);
  int mid = (t[idx].l + t[idx].r) >> 1;
  if (r <= mid)
    add(idx << 1, l, r, w);
  else if (l > mid)
    add(idx << 1 | 1, l, r, w);
  else
    add(idx << 1, l, r, w), add(idx << 1 | 1, l, r, w);
  t[idx].maxn =
      (t[idx << 1].maxn > t[idx << 1 | 1].maxn ? t[idx << 1].maxn
                                               : t[idx << 1 | 1].maxn);
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  build(1, 1, n);
  for (int i = 1; i <= m; i++) {
    l[i] = read(), r[i] = read();
    seg[i * 2 - 1] = l[i], seg[i * 2] = r[i];
  }
  sort(seg + 1, seg + 2 * m + 1), seg[0] = 0;
  int cnt = unique(seg + 1, seg + 2 * m + 1) - seg - 1;
  seg[cnt + 1] = 0x3f3f3f3f;
  int now = 0, f;
  for (int i = 1; i <= n; i++) {
    if (i == seg[now] || (i > seg[now] && i == seg[now + 1])) {
      f = 0, cp.clear();
      if (i == seg[now + 1]) now++;
      for (int j = 1; j <= m; j++) {
        if (l[j] <= i && r[j] >= i)
          f++, add(1, l[j], r[j], -1), cp.push_back(j);
      }
    } else if (i > seg[now]) {
      now++, f = 0, cp.clear();
      for (int j = 1; j <= m; j++) {
        if (l[j] <= seg[now - 1] + 1 && r[j] >= seg[now] - 1)
          f++, add(1, l[j], r[j], -1), cp.push_back(j);
      }
    }
    int minnum = a[i] - f;
    if (t[1].maxn - minnum > ans) {
      ans = t[1].maxn - minnum;
      A = cp;
    }
    if (i == seg[now] - 1 || i == seg[now]) {
      for (int j = 0; j < cp.size(); j++) add(1, l[cp[j]], r[cp[j]], 1);
    }
  }
  printf("%d\n%d\n", ans, A.size());
  for (int i = 0; i < A.size(); i++) printf("%d ", A[i]);
  return 0;
}
