#include <bits/stdc++.h>
using namespace std;
long long int a, b[1000000], lth, min1 = 10e9 + 1, max1 = 0, l = 0, r = 0,
                                  fir = 0, ed = 0;
int main() {
  scanf("%lld", &a);
  for (int i = 1; i <= a; i++) {
    scanf("%lld", &b[i]);
    if (min1 > b[i]) {
      l = i;
      r = l;
      min1 = b[i];
      max1 = 0;
      fir = l;
      ed = l;
    } else if (min1 == b[i]) {
      l = r;
      r = i;
      max1 = max(max1, r - l);
      ed = r;
    }
  }
  max1 = max(max1, a - (ed - fir));
  cout << a * min1 + max1 - 1;
  return 0;
}
