#include <bits/stdc++.h>
using namespace std;
const int MAXNUM = 305;
struct Segment {
  int dif;
  vector<int> v;
};
Segment seg[MAXNUM][MAXNUM];
int a[MAXNUM], l[MAXNUM], d[MAXNUM];
bool pripada(int lev, int des, int tac) { return (tac >= lev && tac <= des); }
void obradi(int i, int j, int m) {
  int v1 = a[i], v2 = a[j];
  for (int k = 0; k < m; k++) {
    if (pripada(l[k], d[k], i + 1) && !pripada(l[k], d[k], j + 1)) {
      v1--;
      seg[i][j].v.push_back(k + 1);
    }
  }
  seg[i][j].dif = v2 - v1;
}
void ispisi_seg(int i, int j) {
  int n = seg[i][j].v.size();
  printf("%d\n%d\n", seg[i][j].dif, n);
  for (int u : seg[i][j].v) printf("%d ", u);
  printf("\n");
}
int main() {
  int n, m, i, j, maxi, maxj, maxd = 0;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 0; i < m; i++) {
    scanf("%d%d", &l[i], &d[i]);
  }
  if (n == 1) {
    printf("0\n0\n");
    return 0;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (i != j) {
        obradi(i, j, m);
        if (seg[i][j].dif > maxd) {
          maxd = seg[i][j].dif;
          maxi = i;
          maxj = j;
        }
      }
    }
  }
  ispisi_seg(maxi, maxj);
  return 0;
}
