#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const long long Mod = 998244353, OO = 2e9;
int n, m;
int l[N], r[N];
int A[N];
vector<int> seg;
int fix(int number) {
  vector<int> ve;
  seg.clear();
  ve.push_back(0);
  for (int i = 1; i <= n; ++i) ve.push_back(A[i]);
  for (int i = 1; i <= m; ++i) {
    if (l[i] > number || r[i] < number) continue;
    seg.push_back(i);
    for (int j = l[i]; j <= r[i]; ++j) {
      ve[j]--;
    }
  }
  swap(ve[0], ve.back());
  ve.pop_back();
  sort(ve.begin(), ve.end());
  return ve.back() - *ve.begin();
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> A[i];
  }
  for (int i = 1; i <= m; ++i) {
    cin >> l[i] >> r[i];
  }
  int mx = 0;
  int val = 0;
  for (int i = 1; i <= n; ++i) {
    if (fix(i) > mx) {
      mx = fix(i);
      val = i;
    }
  }
  cout << fix(val) << endl;
  cout << seg.size() << endl;
  for (auto c : seg) {
    cout << c << " ";
  }
  cout << endl;
}
