#include <bits/stdc++.h>
long long a[200015];
int main() {
  long long n, i;
  while (~scanf("%lld", &n)) {
    long long min = 1111111111;
    for (i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
      if (a[i] <= min) {
        min = a[i];
      }
    }
    for (i = 1; i <= n; i++) {
      a[i] -= min;
    }
    long long s = 0;
    long long m = 0;
    for (i = 1; i <= n; i++) {
      if (a[i])
        s++;
      else {
        if (s > m) m = s;
        s = 0;
      }
    }
    if (a[n]) {
      i = 1;
      while (a[i]) {
        s++;
        i++;
      }
      if (s > m) m = s;
    }
    printf("%lld\n", min * n + m);
  }
  return 0;
}
