Problem: The only difference between easy and hard versions is a number of elements in the array.

You are given an array a consisting of n integers. The value of the i-th element of the array is a_i.

You are also given a set of m segments. The j-th segment is [l_j; r_j], where 1 ≤ l_j ≤ r_j ≤ n.

You can choose some subset of the given set of segments and decrease values on each of the chosen segments by one (independently). For example, if the initial array a = [0, 0, 0, 0, 0] and the given segments are [1; 3] and [2; 4] then you can choose both of them and the array will become b = [-1, -2, -2, -1, 0].

You have to choose some subset of the given segments (each segment can be chosen at most once) in such a way that if you apply this subset of segments to the array a and obtain the array b then the value max_{i=1}^{n}b_i - min_{i=1}^{n}b_i will be maximum possible.

Note that you can choose the empty set.

If there are multiple answers, you can print any.

If you are Python programmer, consider using PyPy instead of Python when you submit your code.

Input

The first line of the input contains two integers n and m (1 ≤ n ≤ 300, 0 ≤ m ≤ 300) — the length of the array a and the number of segments, respectively.

The second line of the input contains n integers a_1, a_2, ..., a_n (-10^6 ≤ a_i ≤ 10^6), where a_i is the value of the i-th element of the array a.

The next m lines are contain two integers each. The j-th of them contains two integers l_j and r_j (1 ≤ l_j ≤ r_j ≤ n), where l_j and r_j are the ends of the j-th segment.

Output

In the first line of the output print one integer d — the maximum possible value max_{i=1}^{n}b_i - min_{i=1}^{n}b_i if b is the array obtained by applying some subset of the given segments to the array a.

In the second line of the output print one integer q (0 ≤ q ≤ m) — the number of segments you apply.

In the third line print q distinct integers c_1, c_2, ..., c_q in any order (1 ≤ c_k ≤ m) — indices of segments you apply to the array a in such a way that the value max_{i=1}^{n}b_i - min_{i=1}^{n}b_i of the obtained array b is maximum possible.

If there are multiple answers, you can print any.

Examples

Input


5 4
2 -2 3 1 2
1 3
4 5
2 5
1 3


Output


6
2
1 4 


Input


5 4
2 -2 3 1 4
3 5
3 4
2 4
2 5


Output


7
2
3 2 


Input


1 0
1000000


Output


0
0

Note

In the first example the obtained array b will be [0, -4, 1, 1, 2] so the answer is 6.

In the second example the obtained array b will be [2, -3, 1, -1, 4] so the answer is 7.

In the third example you cannot do anything so the answer is 0.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T, class V>
bool has(const T &x, V y) {
  return x.find(y) != x.end();
}
template <typename T, typename V>
string to_string(const pair<T, V> &x) {
  return "{" + to_string(x.first) + ", " + to_string(x.second) + "}";
}
void _cerr() { cerr << "]" << endl; }
template <typename T, typename... V>
void _cerr(T t, V... v) {
  cerr << to_string(t);
  if (sizeof...(v) > 0)
    cerr << ", ", _cerr(v...);
  else
    _cerr();
}
inline int nextInt() { return abs(rand() + (rand() << 15)); }
const ll MOD = 1000000007;
const double PI = acos(-1);
inline ll Pow(ll a, ll x, ll p = MOD) {
  ll r = 1;
  for (; x; x >>= 1) {
    if (x & 1) r = r * a % p;
    a = a * a % p;
  }
  return r;
}
inline ll Inv(ll a, ll p = MOD) { return Pow(a % p, p - 2, p); }
inline void Add(ll &a, ll b, ll p = MOD) { a = (a + b) % p; }
inline void Sub(ll &a, ll b, ll p = MOD) {
  a = (a - b) % p;
  if (a < 0) a += p;
}
inline void Mul(ll &a, ll b, ll p = MOD) { a = a * b % p; }
inline ll Lmul(ll a, ll b, ll p = MOD) {
  ll r = 0;
  for (; b; b >>= 1) {
    if (b & 1) r = (r + a) % p;
    a = (a + a) % p;
  }
  return r;
}
template <typename T>
inline T lcm(T a, T b) {
  return a / __gcd(a, b) * b;
}
inline void YES(bool x) { cout << (x ? "YES\n" : "NO\n"); }
inline void Yes(bool x) { cout << (x ? "Yes\n" : "No\n"); }
inline void yes(bool x) { cout << (x ? "yes\n" : "no\n"); }
template <typename T>
inline bool tomax(T &a, T b) {
  return a < b ? a = b, true : false;
}
template <typename T>
inline bool tomin(T &a, T b) {
  return a > b ? a = b, true : false;
}
inline bool bit(ll x, int i) { return (x >> i) & 1; }
inline int bits(ll x) { return __builtin_popcount(x); }
template <typename T>
inline T toggle(T &x, int i) {
  return x ^= (1ll << i);
}
const int LIN = 1e5 + 8;
int t[LIN << 2], f[LIN << 2];
int L[LIN], R[LIN];
vector<int> p[LIN], q[LIN];
int a[LIN];
pair<int, int> s[308];
void init(int k, int l, int r) {
  if (l == r) {
    t[k] = a[l];
    f[k] = 0;
    return;
  }
  int m = (l + r) >> 1;
  init(k << 1, l, m);
  init(k << 1 ^ 1, m + 1, r);
  t[k] = min(t[k << 1], t[k << 1 ^ 1]);
}
void lazy(int k, int l, int r) {
  if (f[k] != 0) {
    t[k] += f[k];
    if (l < r) {
      f[k << 1] += f[k];
      f[k << 1 ^ 1] += f[k];
    }
    f[k] = 0;
  }
}
void update(int k, int l, int r, int x, int y, int v) {
  lazy(k, l, r);
  if (l > y || r < x) return;
  if (l >= x && r <= y) {
    f[k] += v;
    lazy(k, l, r);
    return;
  }
  int m = (l + r) >> 1;
  update(k << 1, l, m, x, y, v);
  update(k << 1 ^ 1, m + 1, r, x, y, v);
  t[k] = min(t[k << 1], t[k << 1 ^ 1]);
}
int get(int k, int l, int r, int x, int y) {
  lazy(k, l, r);
  if (l > y || r < x) return MOD;
  if (l >= x && r <= y) return t[k];
  int m = (l + r) >> 1;
  return min(get(k << 1, l, m, x, y), get(k << 1 ^ 1, m + 1, r, x, y));
}
void solve(int test_number) {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= m; i++) {
    int l, r;
    cin >> l >> r;
    p[r].push_back(l);
    q[l].push_back(r);
    s[i] = {l, r};
  }
  init(1, 1, n);
  memset(f, 0, sizeof f);
  for (int i = 1; i <= n; i++) {
    L[i] = get(1, 1, n, 1, i - 1);
    for (int j : p[i]) {
      update(1, 1, n, j, i, -1);
    }
  }
  init(1, 1, n);
  memset(f, 0, sizeof f);
  for (int i = n; i >= 1; i--) {
    R[i] = get(1, 1, n, i + 1, n);
    NULL;
    for (int j : q[i]) {
      NULL;
      update(1, 1, n, i, j, -1);
    }
  }
  int res = 0;
  vector<int> use;
  for (int i = 1; i <= n; i++) {
    int calc = a[i] - min(L[i], R[i]);
    if (calc > res) {
      res = calc;
      use.clear();
      for (int j = 1; j <= m; j++) {
        if (i < s[j].first || i > s[j].second) {
          use.push_back(j);
        }
      }
    }
  }
  cout << res << endl << (int)(use).size() << endl;
  for (int i : use) cout << i << " ";
}
void solve() {
  int test = 1;
  for (int i = 1; i <= test; i++) {
    solve(i);
  }
}
int main(int argc, char *argv[]) {
  if (argc > 1) {
    freopen(".inp", "r", stdin);
    freopen(".out", "w", stdout);
  }
  ios::sync_with_stdio(false);
  srand(time(NULL));
  solve();
  return 0;
}