#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int res = 0;
  int a[200005], n, i, mm = INT_MAX;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    mm = min(mm, a[i]);
  }
  set<int> second;
  for (i = 1; i <= n; ++i)
    if (a[i] == mm) second.insert(i);
  res = 1ll * mm * n;
  long long int mx = 0;
  for (i = 1; i <= n; ++i) {
    if (a[i] == mm) continue;
    auto it = second.upper_bound(i);
    if (it != second.end())
      mx = max(mx, (long long int)(*it - i));
    else
      mx = max(mx, (long long int)(n - i + *second.begin()));
  }
  res += mx;
  printf("%lld", res);
  return 0;
}
