#include <iostream>
using namespace std;
int interschimbare(int n)
{
int v[n],i,maxim,minim,pmaxim,pminim,aux;
for(i=1;i<=n;i++)
cin>>v[i];
maxim=v[1];
minim=v[1];
for(i=1;i<=n;i++)
{
if(maxim<v[i])
{
maxim=v[i];
pmaxim=i;
}
if(minim>v[i])
{
minim=v[i];
pminim=i;
}
}
cout<<pmaxim<<endl;
cout<<pminim<<endl;
aux=v[pminim];
v[pminim]=v[pmaxim];
v[pmaxim]=aux;
for(i=1;i<=n;i++)
cout<<v[i]<<" ";
return 0;
}
int main()
{
int n;
cin>>n;
interschimbare(n);
return 0;
}