#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long a[n + 1], mn = 1e18, mni = -1, s[n + 1], mnc = 0, mx = -1e18;
  long long x[n + 1];
  memset(x, 0, sizeof(x));
  memset(s, 0, sizeof(s));
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < mn)
      mn = a[i], mni = i, mnc = 1;
    else if (a[i] == mn)
      mnc++;
  }
  a[n] = 0;
  vector<long long> ans;
  vector<pair<long long, long long> > p;
  for (long long i = 0; i < k; i++) {
    long long l, r;
    cin >> l >> r;
    l--;
    r--;
    p.push_back({l, r});
  }
  long long mxx = -1e18;
  for (long long i = 0; i < n; i++) {
    vector<long long> v;
    mn = 1e18, mx = -1e18;
    memset(s, 0, sizeof(s));
    long long b[n + 1];
    memset(b, 0, sizeof(b));
    for (long long j = 0; j < k; j++) {
      long long l = p[j].first, r = p[j].second;
      if (l <= i && i <= r) s[l]--, s[r + 1]++, v.push_back(j + 1);
    }
    for (long long i = 1; i < n + 1; i++) s[i] += s[i - 1];
    for (long long i = 0; i < n; i++) b[i] = a[i] + s[i];
    for (long long i = 0; i < n; i++) {
      if (b[i] > mx) mx = b[i];
      if (b[i] < mn) mn = b[i];
    }
    if (mx - mn > mxx) {
      mxx = mx - mn;
      ans.clear();
      ans = v;
    }
  }
  cout << mxx << "\n";
  cout << ans.size() << "\n";
  for (long long i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
