#include <bits/stdc++.h>
using namespace std;
const int mx = 3e2 + 5;
long long n, m, s[mx], temp[mx], ans, ops;
vector<pair<pair<int, int>, int>> seg[mx];
vector<int> vecans;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    for (int j = l; j < r + 1; j++) {
      seg[j].push_back(make_pair(make_pair(l, r), i + 1));
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      temp[j] = s[j];
    }
    for (int j = 0; j < seg[i].size(); j++) {
      long long l = seg[i][j].first.first, r = seg[i][j].first.second,
                mar = seg[i][j].second;
      for (int j = l; j < r + 1; j++) {
        temp[j]--;
      }
    }
    long long maxx = -1e9, minn = 1e9;
    for (int j = 0; j < n; j++) {
      maxx = max(temp[j], maxx);
      minn = min(temp[j], minn);
    }
    if (maxx - minn > ans) {
      ans = maxx - minn;
      ops = seg[i].size();
      vecans.clear();
      for (int j = 0; j < seg[i].size(); j++) {
        vecans.push_back(seg[i][j].second);
      }
    }
  }
  cout << ans << endl << ops << endl;
  for (int i = 0; i < ops; i++) {
    cout << vecans[i] << " ";
  }
  cout << endl;
  return 0;
}
