#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n + 5);
  vector<int> pos(n + 5);
  vector<int> d(n + 5);
  int min = INT_MAX, minp = -1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] < min) {
      min = a[i];
      minp = i;
    }
  }
  pos[0] = minp;
  int count = 0;
  int j = 0;
  int k = 0;
  for (int i = minp + 1; i <= minp + n; i++) {
    j = i;
    if (j >= n) j -= n;
    if (a[j] == min) {
      k++;
      pos[k] = j;
      d[k - 1] = count;
      count = 0;
    } else {
      count++;
    }
  }
  int maxd = 0;
  for (int i = 0; i < k; i++)
    if (d[i] > maxd) maxd = d[i];
  long long res = ((long long)min) * ((long long)n) + (long long)maxd;
  cout << res << endl;
  return 0;
}
