#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
using namespace std;
long long n, i, j, k, l, sum = 0, flag = 0, ans = 0, m, a[400005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  k = *min_element(a, a + n);
  ans = n * k;
  for (i = 0; i < n; i++) {
    if (a[i] > k)
      a[i] = 1;
    else
      a[i] = 0;
    a[i + n] = a[i];
  }
  long long temp = 0, cnt = 0;
  for (i = 0; i < 2 * n; i++) {
    if (a[i])
      temp++;
    else
      cnt = max(cnt, temp), temp = 0;
  }
  cnt = max(temp, cnt);
  cout << ans + cnt << '\n';
  return 0;
}
