#include<climits>
#include <iostream>
using namespace std;
int main()
{
long long int c1,c2,d,min=1000000000000,g=0,max=0,e,k,i;
long long int ara[200005],n;
cin>>n;
for(i=0;i<n;i++){
cin>>ara[i];
if(ara[i]<min){
min=ara[i];
if(i>0)c1=i;
if(i==0)c1=0;
}
}
for(i=n-1;i>=0;i--){
if(ara[i]==min){
//min1=ara[i];
if(i<n-1)c2=n-i-1;
if(i==n-1)c2=0;
break;
}
}
for(i=0;i<n;i++){
if(e==1&&ara[i]==min)e=0;
if(e==1)g++;
if(ara[i]==min){
if(g>max){
max=g;
g=0;
}
e=1;
}
}
//cout<<max<<" "<<c1<<" "<<c2;;
k=(c1+c2)>max?(c1+c2):max;
d=min*n+k;
cout<<d;
return 0;
}
I2luY2x1ZGU8Y2xpbWl0cz4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKewogICAgbG9uZyBsb25nIGludCBjMSxjMixkLG1pbj0xMDAwMDAwMDAwMDAwLGc9MCxtYXg9MCxlLGssaTsKICAgIGxvbmcgbG9uZyBpbnQgYXJhWzIwMDAwNV0sbjsKICAgIGNpbj4+bjsKICAgIGZvcihpPTA7aTxuO2krKyl7CiAgICAgICAgY2luPj5hcmFbaV07CiAgICAgICAgaWYoYXJhW2ldPG1pbil7CiAgICAgICAgICAgIG1pbj1hcmFbaV07CiAgICAgICAgICAgIGlmKGk+MCljMT1pOwogICAgICAgICAgICBpZihpPT0wKWMxPTA7CiAgICAgICAgfQogICAgfQogICAgZm9yKGk9bi0xO2k+PTA7aS0tKXsKICAgICAgICBpZihhcmFbaV09PW1pbil7CiAgICAgICAgICAgIC8vbWluMT1hcmFbaV07CiAgICAgICAgICAgIGlmKGk8bi0xKWMyPW4taS0xOwogICAgICAgICAgICBpZihpPT1uLTEpYzI9MDsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgfQogICAgZm9yKGk9MDtpPG47aSsrKXsKICAgICAgICBpZihlPT0xJiZhcmFbaV09PW1pbillPTA7CiAgICAgICAgaWYoZT09MSlnKys7CiAgICAgICAgaWYoYXJhW2ldPT1taW4pewogICAgICAgICAgICBpZihnPm1heCl7CiAgICAgICAgICAgICAgICBtYXg9ZzsKICAgICAgICAgICAgICAgIGc9MDsKICAgICAgICAgICAgfQogICAgICAgICAgICBlPTE7CiAgICAgICAgfQogICAgfQogICAgLy9jb3V0PDxtYXg8PCIgIjw8YzE8PCIgIjw8YzI7OwogICAgaz0oYzErYzIpPm1heD8oYzErYzIpOm1heDsKICAgIGQ9bWluKm4razsKICAgIGNvdXQ8PGQ7CiAgICByZXR1cm4gMDsKfQoK