#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long t[n + 10];
  long long mm, pm, s = 0, k, nb = 0, q = 0;
  for (int i = 0; i < n; i++) {
    cin >> t[i];
    if (i == 0) {
      pm = 0;
      mm = t[0];
      k = 0;
    } else {
      if (t[i] < mm) {
        pm = i;
        mm = t[i];
        k = i;
      }
      if (t[i] == mm && i - pm - 1 >= s) {
        s = i - pm - 1;
        pm = i;
      }
    }
  }
  if (pm == k)
    cout << mm * n + n - 1;
  else {
    for (int i = k; i < n; i++) {
      if (t[i] == mm) {
        if (q >= nb) nb = q;
        q = 0;
      } else
        q = q + 1;
    }
    if (q + k >= nb) nb = q + k;
    if (nb == n)
      cout << n * mm;
    else
      cout << n * mm + nb;
  }
}
