#include <bits/stdc++.h>
using namespace std;
long long v[400005];
map<long long, long long> mp;
int main() {
  long long n, pos = 0, ans = 0, aux;
  scanf("%lld", &n);
  long long mn = INT_MAX;
  long long mx = -1ll;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &v[i]);
    mn = min(mn, v[i]);
    mp[v[i]]++;
  }
  if (mp[mn] == 1) {
    for (int i = 0; i < n; i++) {
      if (v[i] == mn) {
        pos = i;
        break;
      }
    }
    printf("%lld\n", n * mn + (n - 1 - pos) + pos);
    return 0;
  }
  for (int i = n; i < 2 * n; i++) v[i] = v[i - n];
  long long a = -1, b = -1;
  mx = -1ll;
  for (int i = 0; i < 2 * n; i++) {
    if (v[i] == mn) {
      if (a == -1)
        a = i;
      else {
        b = i;
        mx = max(mx, b - a - 1ll);
        a = i;
      }
    }
  }
  printf("%lld\n", n * mn + mx);
  return 0;
}
