#include <bits/stdc++.h>
const int MAX_N = (int)2e5 + 123;
const double eps = 1e-6;
const int inf = (int)1e9 + 123;
using namespace std;
long long ans;
int n;
int a[MAX_N];
pair<int, int> pref[MAX_N], suff[MAX_N];
int main() {
  cin >> n;
  int mini = inf;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mini = min(mini, a[i]);
  }
  for (int i = 1; i <= n; i++) {
    pref[i] = make_pair(a[i], i);
    if (i > 1 && pref[i].first >= pref[i - 1].first) pref[i] = pref[i - 1];
  }
  for (int i = n; i > 0; i--) {
    suff[i] = make_pair(a[i], i);
    if (i < n && suff[i].first > suff[i + 1].first) suff[i] = suff[i + 1];
  }
  for (int i = 1; i <= n; i++) {
    if (suff[i].first == mini) {
      ans = max(ans, 1ll * mini * n + 1ll * suff[i].second - i);
      continue;
    } else
      ans = max(ans, 1ll * mini * n + n - i + 1 + pref[i].second - 1);
  }
  cout << ans;
  return 0;
}
