#include <bits/stdc++.h>
using namespace std;
const long long Nmax = 2000;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  pair<int, int> s[m];
  for (int i = 0; i < m; i++) cin >> s[i].first >> s[i].second;
  int ans = -1000000000;
  int cnt = m + 1;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int a[n + 1];
    int temp = 0;
    vector<int> t;
    for (int j = 0; j < n; j++) a[j] = arr[j];
    for (int j = 0; j < m; j++) {
      if (s[j].first <= i + 1 && i + 1 <= s[j].second) continue;
      for (int k = s[j].first - 1; k < s[j].second; k++) a[k]--;
      temp++;
      t.push_back(j + 1);
    }
    int x = a[0];
    for (int j = 0; j < n; j++) x = min(x, a[j]);
    if (ans >= abs(x - arr[i])) continue;
    ans = max(abs(x - arr[i]), ans);
    cnt = temp;
    v = t;
  }
  cout << ans << endl;
  ;
  cout << cnt << endl;
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  return 0;
}
