#include <bits/stdc++.h>
using namespace std;
int Array[305], Temp[305];
pair<int, int> Segments[305];
vector<int> V;
int main() {
  int N, m, i;
  scanf("%d%d", &N, &m);
  for (i = 1; i <= N; ++i) scanf("%d", Array + i);
  for (i = 1; i <= m; ++i)
    scanf("%d%d", &Segments[i].first, &Segments[i].second);
  int Ans = 0, j, k, Max, Min, index;
  for (i = 1; i <= N; ++i) {
    for (j = 1; j <= N; ++j) Temp[j] = Array[j];
    for (j = 1; j <= m; ++j) {
      if (i >= Segments[j].first && i <= Segments[j].second) {
        for (k = Segments[j].first; k <= Segments[j].second; ++k) --Temp[k];
      }
    }
    Max = -10000000;
    Min = 10000000;
    for (j = 1; j <= N; ++j) {
      Max = max(Max, Temp[j]);
      Min = min(Min, Temp[j]);
    }
    if (Max - Min > Ans) {
      index = i;
      Ans = Max - Min;
    }
  }
  for (i = 1; i <= m; ++i) {
    if (index >= Segments[i].first && index <= Segments[i].second)
      V.emplace_back(i);
  }
  printf("%d\n%d\n", Ans, int(V.size()));
  for (i = 0; i < V.size(); ++i) printf("%d ", V[i]);
  puts("");
  return 0;
}
