#include <bits/stdc++.h>
using namespace std;
int n, a[200005], mini;
vector<int> v;
int main() {
  mini = 1e9 + 1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (mini > a[i]) {
      mini = a[i];
      v.clear();
      v.push_back(i);
    } else if (mini == a[i])
      v.push_back(i);
  }
  int maxlong = 0;
  if (v.size() >= 2) {
    for (int i = 1; i < v.size(); i++) {
      maxlong = max(maxlong, v[i] - v[i - 1] - 1);
    }
    maxlong = max(maxlong, n - v.back() + v[0] - 1);
  } else
    maxlong = n - 1;
  long long ans = 1LL * n * mini;
  ans += maxlong;
  cout << ans;
}
