#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
int ln=a[1];
for (i=1; i<=n; i++) ln=max(ln,a[i]);
cout<<ln<<endl;
for (i=1; i<=n; i++)
if (ln==a[i]) cout<<i<<" ";
cout<<endl;
int nn=a[1];
for (i=1; i<=n; i++) nn=min(nn,a[i]);
cout<<nn<<endl;
for (i=1; i<=n; i++)
if (nn==a[i]) cout<<i<<" ";
cout<<endl;
int t=0;
for (i=1; i<=n; i++) if (i%2==0) t+=a[i]*a[i];
cout<<t<<endl;
sort(a+1,a+n+1);
for (i=1; i<=n; i++) cout<<a[i]<<" ";
}