#include <bits/stdc++.h>
using namespace std;
long long a[200005];
int main() {
  long long n;
  cin >> n;
  long long M = 2147483647, p, pp;
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] < M) {
      M = a[i];
    }
  }
  for (int i = 0; i < n; ++i)
    if (a[i] == M) v.push_back(i);
  long long MM = 0;
  for (int i = 1; i < v.size(); ++i) {
    if (v[i] - v[i - 1] - 1 > MM) MM = v[i] - v[i - 1] - 1;
  }
  MM = max(MM, (long long)n - 1 - v[v.size() - 1] + v[0]);
  cout << n * M + MM << endl;
}
