#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e9;
const int N = 2 * 1e5 + 1;
const double eps = 1e-5;
string s;
int n, dp[N][4];
char C[3] = {'R', 'G', 'B'};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, a[301], b[301], m, r, l;
  vector<pair<int, int>> seg;
  vector<int> ans, tmp;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> l >> r;
    l--, r--;
    seg.push_back({l, r});
  }
  int ansdiff = -oo;
  for (int i = 0; i < n; i++) {
    for (int i = 0; i < n; i++) {
      b[i] = a[i];
    }
    for (int j = 0; j < seg.size(); j++) {
      l = seg[j].first, r = seg[j].second;
      if (i < l || i > r) {
        for (int k = l; k <= r; k++) {
          b[k]--;
        }
        tmp.push_back(j + 1);
      }
    }
    sort(b, b + n);
    if (b[n - 1] - b[0] > ansdiff) {
      ansdiff = b[n - 1] - b[0];
      ans = tmp;
    }
    tmp.clear();
  }
  cout << ansdiff << endl;
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
}
