#include <bits/stdc++.h>
using namespace std;
long long a[400005];
int main() {
  long long i, sum = 0, res = 0, ans, n, an;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  an = a[0];
  for (i = 0; i < n; i++) {
    an = min(a[i], an);
  }
  for (i = n; i < 2 * n; i++) {
    a[i - n] -= an;
    a[i] = a[i - n];
  }
  for (i = 0; i < 2 * n; i++) {
    if (a[i] != 0) {
      sum = sum + 1;
    } else {
      res = max(sum, res);
      sum = 0;
    }
  }
  res = max(res, sum);
  if (res >= n) res = n;
  ans = an * n + res;
  cout << ans << endl;
  return 0;
}
