#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535;
long long powi(long long base, int p) {
  long long res = 1;
  while (p--) res *= base;
  return res;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
bool is_vowel(char c) {
  c = tolower(c);
  return c == 'a' || c == 'e' || c == 'o' || c == 'i' || c == 'u' || c == 'y';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  long long mn = INT_MAX;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < mn) mn = a[i];
  }
  int bst_ix = -1, mx = INT_MIN;
  for (int i = 0; i < n; i++) {
    if (a[i] != mn) continue;
    int ix = (i + 1) % n;
    int cum = 0;
    while (a[ix] != mn) {
      cum++;
      ix += 1;
      if (ix == n) ix = 0;
    }
    if (cum > mx) {
      bst_ix = (i + 1) % n;
      mx = cum;
    }
  }
  long long res = mn * n;
  while (a[bst_ix] != mn) {
    res++;
    bst_ix++;
    if (bst_ix == n) bst_ix = 0;
  }
  cout << res;
  return 0;
}
