#include <bits/stdc++.h>
using namespace std;
void printv(vector<int> v) {
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << endl;
}
unsigned long long summ(unsigned long long n) { return ((n * n) + n) / 2; }
bool isubseq(string scanf, string& s1) {
  int ln = s1.length(), lll = scanf.length();
  int i = 0, j = 0;
  for (; i < ln && j < lll; i++) j += (s1[i] == scanf[j]);
  return j == lll;
}
string to_string(int val) {
  if (!val) return "0";
  string scanf;
  while (val) {
    scanf += val % 10 + 48;
    val /= 10;
  }
  reverse(scanf.begin(), scanf.end());
  return scanf;
}
bool incirc(double x, double y, double center_x, double center_y, double r) {
  return (x - center_x) * (x - center_x) + (y - center_y) * (y - center_y) <=
         r * r;
}
unsigned long long gcd(unsigned long long a, unsigned long long b) {
  unsigned long long c;
  while (a != 0) {
    c = a;
    a = b % a;
    b = c;
  }
  return b;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  while (cin >> n) {
    long long arr[n];
    for (int i = 0; i < n; cin >> arr[i++])
      ;
    long long minn = *min_element(arr, arr + n), pl = 0;
    for (int i = 0; i < n; arr[i++] -= minn)
      ;
    for (int i = 0; i < n; i++) {
      if (arr[i])
        pl++;
      else
        break;
    }
    int z = -1;
    int marr[n];
    for (int i = n - 1; i >= 0; i--) {
      if (!arr[i]) {
        z = i;
      }
      marr[i] = z;
    }
    long long res = minn * n, tt = 0;
    long long rr = 0;
    for (int i = 0; i < n; i++) {
      if (arr[i])
        if (marr[i] == -1) {
          rr = (n - i) + min(pl, (long long)i);
        } else {
          rr = marr[i] - i;
        }
      tt = max(tt, rr);
    }
    res += tt;
    cout << res << endl;
  }
}
