#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200002;
long long int n, i, t[MAXN], m = INT_MAX, a, ans;
int main() {
  for (cin >> n; cin >> t[i]; i++) m = min(m, t[i]);
  for (i = 0; i < 2 * n; ++i) {
    t[i % n] > m ? a++ : a = 0;
    ans = max(a, ans);
  }
  cout << ans + m * n;
}
