#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[401000];
long long dis[401000];
long long m = (1e9 + 100), num;
long long ans;
long long l, r;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  ofstream fout("badmilk.out");
  ifstream fin("badmilk.in");
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i + n] = a[i];
    if (a[i] < m) {
      m = a[i];
    }
  }
  for (int i = (2 * n - 1); i > -1; i--) {
    if (a[i] == m) {
      r = 0;
    }
    dis[i] = r;
    r++;
  }
  for (int i = 0; i < n; i++) {
    ans = max(ans, dis[i]);
  }
  ans += m * n;
  cout << ans;
  return 0;
}
