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.
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long MOD = 1e9 + 7;
const long long MOD2 = 998244353;
double eps = 1e-12;
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<
                                    !is_same<T_container, string>::value,
                                    typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v) {
  os << '{';
  string sep;
  for (const T &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
template <typename T>
void get_ar(T *ar, long long n) {
  for (long long i = 0; i < n; i++) cin >> ar[i];
}
template <typename T>
void printar(T *ar, long long n) {
  for (long long i = 0; i < n; i++) cout << ar[i] << " ";
  cout << "\n";
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long imod(long long a, long long m) { return power(a, m - 2, m); }
template <typename T, size_t N, size_t M>
void print2dArray(T (&theArray)[N][M], long long n = N, long long m = M) {
  for (long long x = 0; x < n; x++) {
    for (long long y = 0; y < m; y++) {
      cout << theArray[x][y] << " ";
    }
    cout << "\n";
  }
}
template <typename T, size_t N>
void print_ar(T (&theArray)[N], long long n = N) {
  for (long long x = 0; x < n; x++) {
    cout << theArray[x] << " ";
  }
  cout << "\n";
}
long long a[200005];
struct node {
  long long val;
  node() { val = INT_MAX; }
};
class segte {
 public:
  long long n{};
  vector<node> tree;
  vector<long long> lazy;
  vector<bool> prsnt;
  node neutral;
  void init(long long N) {
    n = N;
    tree.resize(4 * n + 1);
    lazy.assign(4 * n + 1, 0);
    prsnt.assign(4 * n + 1, false);
  }
  static void merge(node &curr, node &left, node &right) {
    curr.val = min(left.val, right.val);
  }
  void prop(long long index, long long ss, long long second) {
    tree[index].val += lazy[index];
    if (ss != second) {
      lazy[2 * index] += lazy[index];
      lazy[2 * index + 1] += lazy[index];
      prsnt[2 * index] = prsnt[2 * index + 1] = true;
    }
    lazy[index] = 0;
    prsnt[index] = false;
  }
  void build(long long index, long long ss, long long second) {
    if (ss == second) {
      tree[index].val = a[ss];
      return;
    }
    long long mid = (ss + second) / 2;
    build(2 * index, ss, mid);
    build(2 * index + 1, mid + 1, second);
    merge(tree[index], tree[2 * index], tree[2 * index + 1]);
  }
  void build() { build(1, 0, n - 1); }
  node query(long long index, long long ss, long long second, long long qs,
             long long qe) {
    if (prsnt[index]) prop(index, ss, second);
    if (qs > second || qe < ss) return neutral;
    if (qs <= ss && qe >= second) return tree[index];
    long long mid = (ss + second) / 2;
    node left = query(2 * index, ss, mid, qs, qe);
    node right = query(2 * index + 1, mid + 1, second, qs, qe);
    node mer;
    merge(mer, left, right);
    return mer;
  }
  node query(long long l, long long r) { return query(1, 0, n - 1, l, r); }
  void update(long long index, long long ss, long long second, long long l,
              long long r, long long inc) {
    if (prsnt[index]) prop(index, ss, second);
    if (r < ss || l > second) return;
    if (ss >= l && second <= r) {
      prsnt[index] = true;
      lazy[index] += inc;
      prop(index, ss, second);
      return;
    }
    long long mid = (ss + second) / 2;
    update(2 * index, ss, mid, l, r, inc);
    update(2 * index + 1, mid + 1, second, l, r, inc);
    merge(tree[index], tree[2 * index], tree[2 * index + 1]);
  }
  void update(long long l, long long r, long long inc) {
    update(1, 0, n - 1, l, r, inc);
  }
};
void solve() {
  long long n, K, ans = 0, tmp, m;
  cin >> n >> m;
  long long ar[n];
  vector<pair<long long, long long> > seg;
  get_ar(ar, n);
  segte tree;
  tree.init(n);
  for (long long i = 0; i < n; i++) {
    a[i] = ar[i];
  }
  tree.build();
  set<long long> best;
  map<long long, vector<vector<long long> > > toadd;
  map<long long, vector<vector<long long> > > torem;
  set<long long> cur;
  for (long long i = 0; i < m; i++) {
    long long a1, b;
    cin >> a1 >> b;
    a1--;
    b--;
    seg.emplace_back(a1, b);
    tree.update(a1, b, -1);
    toadd[a1].push_back({a1, b, i + 1});
    torem[b + 1].push_back({a1, b, i + 1});
    cur.insert(i + 1);
  }
  for (long long i = 0; i < n; i++) {
    for (auto x : toadd[i]) {
      long long a1 = x[0];
      long long b = x[1];
      long long ind = x[2];
      tree.update(a1, b, 1);
      cur.erase(ind);
    }
    for (auto x : torem[i]) {
      long long a1 = x[0];
      long long b = x[1];
      long long ind = x[2];
      tree.update(a1, b, -1);
      cur.insert(ind);
    }
    long long va = tree.query(0, n - 1).val;
    long long temp = ar[i] - va;
    if (temp > ans) {
      ans = temp;
      best = cur;
    }
  }
  cout << ans << "\n";
  cout << (long long)best.size() << "\n";
  for (auto x : best) cout << x << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  for (long long it = 1; it <= t; it++) {
    solve();
  }
  return 0;
}
