#include <bits/stdc++.h>
using namespace std;
const int N = 2000001, md = 1e9 + 7;
const double Eps = 0.01;
using namespace std;
int n, a[N], mac;
long long ans;
set<int> S;
int main() {
  cin >> n;
  mac = 1e9 + 4;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mac = min(mac, a[i]);
  }
  for (int i = 1; i <= n; i++)
    if (mac == a[i]) S.insert(i), S.insert(i + n);
  ans = mac * 1ll * n;
  mac = 0;
  for (int i = 1; i <= n; i++) mac = max(mac, *S.lower_bound(i) - i);
  cout << ans + mac;
}
