#include <bits/stdc++.h>
#define len(a) sizeof(a)/sizeof(a[0])
using namespace std;
#define ll long long
#define fill(a,x) memset(a,x,sizeof(a));
const ll m = 1e9+7;
int main(){
ll n; cin >> n;
ll a[n],m = 1e9+1;
ll d = 0,s = 0;
for(ll i = 0; i < n; i++) cin >> a[i], m = min(m,a[i]);
d = find(a,a+n,m) - a;
for(ll i = n-1; i >= 0; i--){
if(a[i] == m){
s = max(s,d);
d = 0;
}
else d += 1;
}
// cout << first << " " << last << endl;
// cout << d << endl;
cout << m*n + s;
}
85. Maximal Rectangle | 84. Largest Rectangle in Histogram |
60. Permutation Sequence | 42. Trapping Rain Water |
32. Longest Valid Parentheses | Cutting a material |
Bubble Sort | Number of triangles |
AND path in a binary tree | Factorial equations |
Removal of vertices | Happy segments |
Cyclic shifts | Zoos |
Build a graph | Almost correct bracket sequence |
Count of integers | Differences of the permutations |
Doctor's Secret | Back to School |
I am Easy | Teddy and Tweety |
Partitioning binary strings | Special sets |
Smallest chosen word | Going to office |
Color the boxes | Missing numbers |
Maximum sum | 13 Reasons Why |