#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  long long ans = 0;
  long long mn = 1e9 + 5;
  for (auto x : a) mn = min((long long)x, mn);
  ans = mn * 1ll * n;
  for (int i = 0; i < n; ++i) a[i] -= mn;
  int best = 0;
  for (int i = 0; i < n; ++i) {
    int j = (i + 1) % n;
    if (a[i] == 0 && a[j] >= 1) {
      int tmp = 0;
      while (a[j] >= 1) {
        ++j;
        ++tmp;
        if (j == n) j = 0;
      }
      best = max(tmp, best);
      if (j <= i) break;
      if (tmp != 0) i = j - 1;
    }
  }
  cout << ans + best << endl;
  return 0;
}
