#include <bits/stdc++.h>
using namespace std;
long long a[2000005], min1 = 1000000005, max1 = 0, b[2000005];
int main() {
  long long n, i, j, l = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    if (min1 > a[i]) min1 = a[i];
  }
  for (i = 1; i <= n; i++)
    if (a[i] == min1) {
      l++;
      b[l] = i;
    }
  for (i = 1; i < l; i++) {
    long long k = b[i + 1] - b[i] - 1;
    if (k > max1) max1 = k;
  }
  long long k = n - b[l] + b[1] - 1;
  if (k > max1) max1 = k;
  cout << min1 * n + max1;
  return 0;
}
