#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  pair<long long, long long> p[100007];
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    p[i] = make_pair(x, y);
  }
  long long ans = -10000000;
  long long index = -1;
  for (long long i = 0; i < n; i++) {
    long long b[100007];
    for (long long k = 0; k < n; k++) {
      b[k] = a[k];
    }
    for (long long j = 0; j < m; j++) {
      long long x = p[j].first;
      long long y = p[j].second;
      if (i + 1 >= x && i + 1 <= y) {
        continue;
      } else {
        for (long long k = x - 1; k < y; k++) {
          b[k]--;
        }
      }
    }
    long long min = LLONG_MAX;
    for (long long k = 0; k < n; k++) {
      if (b[k] < min) {
        min = b[k];
      }
    }
    if (a[i] - min > ans) {
      ans = a[i] - min;
      index = i;
    }
  }
  cout << ans << endl;
  vector<long long> ans2;
  for (long long i = 0; i < m; i++) {
    long long x = p[i].first;
    long long y = p[i].second;
    if (index + 1 >= x && index + 1 <= y) {
      continue;
    } else {
      ans2.push_back(i + 1);
    }
  }
  cout << ans2.size() << endl;
  for (long long i = 0; i < ans2.size(); i++) {
    cout << ans2[i] << " ";
  }
  return 0;
}
