#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
int tree[4 * N], lazy[4 * N], arr[N];
vector<bool> used(N), ans(N);
int n, m;
pair<int, int> b[N];
void build(int pos, int l, int r) {
  if (l == r) {
    tree[pos] = arr[l];
    return;
  }
  int mid = (l + r) / 2;
  build(pos << 1, l, mid);
  build(pos << 1 | 1, mid + 1, r);
  tree[pos] = min(tree[pos << 1], tree[pos << 1 | 1]);
}
void propagate_lazy(int pos, int l, int r) {
  tree[pos] += lazy[pos];
  if (l != r)
    lazy[pos << 1] += lazy[pos], lazy[pos << 1 | 1] += lazy[pos], lazy[pos] = 0;
  lazy[pos] = 0;
}
void update(int pos, int l, int r, int qLow, int qHigh, int v) {
  propagate_lazy(pos, l, r);
  if (l > qHigh || r < qLow) return;
  if (l >= qLow && r <= qHigh) {
    lazy[pos] += v;
    propagate_lazy(pos, l, r);
    return;
  }
  int mid = (l + r) >> 1;
  update(pos << 1, l, mid, qLow, qHigh, v);
  update(pos << 1 | 1, mid + 1, r, qLow, qHigh, v);
  tree[pos] = min(tree[pos << 1], tree[pos << 1 | 1]);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  for (int i = 0; i < m; i++)
    scanf("%d%d", &b[i].first, &b[i].second), b[i].first--, b[i].second--;
  build(1, 0, n - 1);
  int best = -1e9;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (used[j]) {
        if (i >= b[j].first && i <= b[j].second) {
          update(1, 0, n - 1, b[j].first, b[j].second, 1);
          used[j] = false;
        }
      } else {
        if (i < b[j].first || i > b[j].second) {
          update(1, 0, n - 1, b[j].first, b[j].second, -1);
          used[j] = true;
        }
      }
    }
    if (arr[i] - tree[1] > best) {
      best = arr[i] - tree[1];
      ans = used;
    }
  }
  int cnt = 0;
  for (int i = 0; i < m; i++)
    if (ans[i]) cnt++;
  printf("%d\n", best);
  printf("%d\n", cnt);
  for (int i = 0; i < m; i++)
    if (ans[i]) printf("%d ", i + 1);
  return 0;
}
