#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  long long mini = 10000000000;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    mini = min(mini, v[i]);
  }
  long long start = -1;
  long long from = -1;
  long long ans = 0;
  for (int i = 0; 1; i = (i + 1) % n) {
    if (start == -1) {
      if (v[i] == mini) {
        start = i;
        from = i;
      }
    } else if (start == i) {
      ans = max(ans, (i - from + n) % n);
      break;
    } else if (v[i] == mini) {
      ans = max(ans, (i - from + n) % n);
      from = i;
    }
  }
  if (ans == 0) ans = n;
  cout << n * mini + ans - 1 << endl;
  return 0;
}
