#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, A[200001] = {}, mn = (long long)1e9;
  cin >> n;
  for (int x = 0; x < n; x++) cin >> A[x], mn = min(mn, A[x]);
  vector<int> pos;
  for (int x = 0; x < n; x++)
    if (A[x] == mn) pos.push_back(x);
  int j = 0;
  long long mx = 0;
  for (int x = 0; x < n; x++) {
    mx =
        max(mx, x <= pos[j] ? abs((long long)x - pos[j]) : abs(n - x + pos[j]));
    if (A[x] == mn) j++, j %= pos.size();
  }
  cout << mx + mn * n << endl;
}
