https://codeforces.com/contest/1108/problem/E1
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn=1e5+5;
ll n,m;
int main(){
cin>>n>>m;
vector<ll> a(n),ans;
vector<pair<ll,ll> > b(m);
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<m;i++){
cin>>b[i].first>>b[i].second;
b[i].first--; b[i].second--;
}
ll res=*max_element(a.begin(),a.end()) - *min_element(a.begin(),a.end());
for(int i=0;i<n;i++){
vector<ll> del(n),seq;
ll minn=INF,maxx=-INF;
for(int j=0;j<m;j++)
{
if(i>=b[j].first && i<=b[j].second)
continue;
seq.push_back(j);
for(int k=b[j].first;k<=b[j].second;k++){
del[k]--;
}
}
for(int j=0;j<n;j++){
maxx=max(maxx,a[j]+del[j]);
minn=min(minn,a[j]+del[j]);
}
if(maxx-minn>res){
res=maxx-minn;
ans=seq;
}
}
cout<<res<<endl<<ans.size()<<endl;
for(auto k:ans){
cout<<k+1<<" ";
}
cout<<endl;
return 0;
}