#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  vector<pair<int, int>> q;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    q.push_back({x, y});
  }
  int ans = -100000000;
  int idx = -1;
  vector<int> anss;
  for (int i = 0; i < n; i++) {
    vector<int> v1 = v, a;
    int c = -1;
    for (auto j : q) {
      c++;
      if (!(j.first <= i && j.second >= i)) continue;
      for (int k = j.first; k <= j.second; k++) v1[k]--;
      a.push_back(c + 1);
    }
    if (ans < *max_element(v1.begin(), v1.end()) -
                  *min_element(v1.begin(), v1.end())) {
      idx = i;
      anss = a;
      ans = *max_element(v1.begin(), v1.end()) -
            *min_element(v1.begin(), v1.end());
    }
  }
  cout << ans << endl;
  cout << (int)anss.size() << endl;
  for (auto i : anss) cout << i << " ";
  return 0;
}
