#include <bits/stdc++.h>
using namespace std;
long long int tc = 1;
void solve() {
  long long int n;
  cin >> n;
  long long int a[2 * n], mini = INT_MAX;
  for (long long int i = 0, j = 0, k = 0; i < n, j < n, k < n; i++, j++, k++) {
    cin >> a[i];
    mini = min(mini, a[i]);
    a[i + n] = a[i];
  }
  vector<long long int> v;
  long long int temp = 0;
  for (long long int i = 0, j = 0, k = 0; i < 2 * n, j < 2 * n, k < 2 * n;
       i++, j++, k++) {
    if (a[i] == mini) {
      v.emplace_back(temp);
      temp = 0;
    } else
      temp++;
  }
  sort(v.begin(), v.end());
  long long int x = v.size();
  cout << n * mini + v[x - 1] << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
