#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n + n);
  long long mn = INF;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    a[i + n] = a[i];
    mn = min(mn, a[i]);
  }
  vector<long long> idx;
  for (long long i = 0; i < 2 * n; i++) {
    if (a[i] == mn) idx.push_back(i);
  }
  long long mx = 0;
  for (long long i = 0; i < ((long long)(idx).size()) - 1; i++) {
    mx = max(mx, idx[i + 1] - idx[i]);
  }
  cout << mn * n + mx - 1 << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  clock_t beg = clock();
  long long t = 1;
  while (t--) {
    solve();
  }
  cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}
