#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, i, j, pos, k, n, m, min, sum = 0, max = 0, sum1, c1 = 0,
                                        flag = 0, count = 0;
  long long a[200005], b[200005];
  scanf("%I64d", &n);
  for (i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
    sum += a[i];
  }
  min = a[0];
  pos = 0;
  for (i = 0; i < n; i++) {
    if (a[i] < min) {
      min = a[i];
      pos = i;
    }
  }
  for (i = n - 1; i >= 0; i--) {
    if (a[i] == min) {
      b[i] = count;
      flag = 1;
      count = 0;
    }
    if (flag == 0) {
      c1++;
    }
    if (a[i] != min) {
      count++;
      b[i] = 0;
    }
  }
  c1 += count;
  for (i = 0; i < n; i++) {
    if (b[i] > max) max = b[i];
  }
  if (c1 > max) max = c1;
  sum1 = n * min;
  sum1 += max;
  printf("%I64d", sum1);
  return 0;
}
