#include <bits/stdc++.h>
using namespace std;
int a[4269407];
vector<int> mins;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int minn = 2000000000;
  for (int i = 1; i <= n; i++) {
    if (a[i] == minn)
      mins.push_back(i);
    else if (a[i] < minn) {
      minn = a[i];
      mins.clear();
      mins.push_back(i);
    }
  }
  int maxd = 0;
  mins.push_back(n + mins[0]);
  for (int i = 0; i + 1 < mins.size(); i++) {
    maxd = max(maxd, mins[i + 1] - mins[i]);
  }
  cout << (long long)n * minn + maxd - 1 << endl;
  return 0;
}
