#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int l[m + 1], r[m + 1];
  for (int i = 1; i <= m; i++) cin >> l[i] >> r[i];
  vector<int> ansInd;
  int d = -1000000000;
  for (int i = 1; i <= n; i++) {
    vector<int> tempInd;
    vector<int> temp(n + 1);
    for (int i = 1; i <= n; i++) temp[i] = a[i];
    for (int j = 1; j <= m; j++) {
      if (!(i >= l[j] && i <= r[j])) {
        for (int i1 = l[j]; i1 <= r[j]; i1++) temp[i1]--;
        tempInd.push_back(j);
      }
    }
    int tempD = *max_element(temp.begin() + 1, temp.end()) -
                *min_element(temp.begin() + 1, temp.end());
    if (tempD > d) {
      d = tempD;
      ansInd.clear();
      for (int j = 0; j < tempInd.size(); j++) ansInd.push_back(tempInd[j]);
    }
  }
  cout << d << endl << ansInd.size() << endl;
  for (int i = 0; i < ansInd.size(); i++) cout << ansInd[i] << " ";
  return 0;
}
