#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 25, oo = 1e9 + 7;
int main() {
  int n, a, x, mn = oo, idx1, idx2;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a < mn) {
      mn = a;
      x = 0;
      idx1 = i;
      idx2 = i;
    } else if (a == mn) {
      x = max(x, i - idx2 - 1);
      idx2 = i;
    }
  }
  x = max(x, n - (idx2 - idx1 + 1));
  printf("%lld\n", 1ll * n * mn + x);
  return 0;
}
