#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9;
int n, m, a[100000 + 1], ans[100000 + 1];
vector<pair<int, int> > lt[100000 + 1], rt[100000 + 1];
struct segment_tree {
  int it[4 * 100000], lazy[4 * 100000];
  void init(int id, int l, int r) {
    if (l == r) {
      it[id] = a[l];
      lazy[id] = 0;
      return;
    }
    int mid = (l + r) / 2;
    init(2 * id, l, mid);
    init(2 * id + 1, mid + 1, r);
    lazy[id] = 0;
    it[id] = min(it[2 * id], it[2 * id + 1]);
  }
  void upd(int id, int l, int r, int l1, int r1) {
    if (r < l1 || r1 < l) return;
    if (l1 <= l && r <= r1) {
      it[id]--;
      lazy[id]--;
      return;
    }
    int mid = (l + r) / 2;
    upd(2 * id, l, mid, l1, r1);
    upd(2 * id + 1, mid + 1, r, l1, r1);
    it[id] = min(it[2 * id], it[2 * id + 1]) + lazy[id];
  }
  int get(int id, int l, int r, int l1, int r1) {
    if (r < l1 || r1 < l) return oo;
    if (l1 <= l && r <= r1) return it[id];
    int mid = (l + r) / 2;
    return min(get(2 * id, l, mid, l1, r1),
               get(2 * id + 1, mid + 1, r, l1, r1)) +
           lazy[id];
  }
} IT;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int l, r;
  for (int i = 1; i <= m; i++) {
    cin >> l >> r;
    lt[l].push_back({r, i});
    rt[r].push_back({l, i});
  }
  IT.init(1, 1, n);
  for (int i = 1; i <= n; i++) {
    int foo = IT.get(1, 1, n, 1, i);
    ans[i] = max(ans[i], a[i] - foo);
    for (int j = 0; j < rt[i].size(); j++) {
      IT.upd(1, 1, n, rt[i][j].first, i);
    }
  }
  IT.init(1, 1, n);
  for (int i = n; i >= 1; i--) {
    int foo = IT.get(1, 1, n, i, n);
    ans[i] = max(ans[i], a[i] - foo);
    for (int j = 0; j < lt[i].size(); j++) {
      IT.upd(1, 1, n, i, lt[i][j].first);
    }
  }
  int ANS = 0, id = 0;
  for (int i = 1; i <= n; i++) {
    if (ANS < ans[i]) {
      ANS = ans[i];
      id = i;
    }
  }
  cout << ANS << '\n';
  vector<int> v;
  for (int i = 1; i <= n; i++) {
    if (i < id) {
      for (int j = 0; j < rt[i].size(); j++) v.push_back(rt[i][j].second);
    }
    if (i > id) {
      for (int j = 0; j < lt[i].size(); j++) v.push_back(lt[i][j].second);
    }
  }
  cout << v.size() << '\n';
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << '\n';
}
