#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> aa(2 * n);
  long long m = 1e9 + 1;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    aa[i] = a[i];
    aa[i + n] = a[i];
    m = min(m, a[i]);
  }
  long long pos = -1;
  long long ma = -1;
  for (long long i = 0; i < 2 * n; i++) {
    if (aa[i] == m) {
      if (pos != -1) ma = max(ma, i - pos - 1);
      pos = i;
      continue;
    }
  }
  long long extra = ma;
  if (pos == -1) extra = n - 1;
  long long ans = n * m + extra;
  cout << ans << endl;
  return 0;
}
