#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e6 + 7;
int main() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n + 10, 0), b;
  vector<pair<int, int>> v;
  vector<int> cnt(n + 10, 0), cnt1(n + 10, 0);
  set<int> s;
  for (int i = 1; i <= n; i++) cin >> a[i], s.insert(a[i]);
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    cnt[l]++;
    cnt1[r]++;
    v.push_back({l, r});
  }
  vector<int> ans;
  int ans_mx = 0;
  for (int i = 1; i <= n; i++) {
    b = a;
    vector<int> union_segment, l(n + 10, 0), r(n + 10, 0);
    for (int j = 0; j < v.size(); j++) {
      if (v[j].second < i || v[j].first > i) {
        l[v[j].first]++;
        r[v[j].second]++;
        union_segment.push_back(j + 1);
      }
    }
    int val = 0;
    for (int j = 1; j <= n; j++) {
      val += l[j];
      b[j] -= val;
      val -= r[j];
    }
    int mi = 1e9, mx = -1e9;
    for (int j = 1; j <= n; j++) {
      mx = max(mx, b[j]), mi = min(mi, b[j]);
    }
    if (mx - mi > ans_mx) {
      ans_mx = mx - mi;
      ans = union_segment;
    }
  }
  cout << ans_mx << '\n';
  cout << ans.size() << '\n';
  for (int i : ans) cout << i << ' ';
}
