#include <bits/stdc++.h>
int const N = 1e6 + 7;
using namespace std;
long long n, k, x, ans, p, y, z, mi, mx, i, j, sum, t, m, d, a, b, q, l, r, s1,
    s2;
long long arr[N], dp[N];
char mat[1001][1002];
string st;
char tt;
vector<pair<long long, long long> > vt, kt[26];
vector<int> aa[100001];
bool used[26];
int flag = 0;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
vector<long long> pt;
int main() {
  cin >> n;
  mi = INT_MAX;
  k = 0;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] < mi) mi = arr[i];
  }
  for (i = 0; i < n; i++) {
    if (arr[i] == mi) {
      pt.push_back(i);
    }
  }
  if (pt.size() == 1)
    k = n - 1;
  else {
    k = n - pt[pt.size() - 1] + pt[0] - 1;
    for (i = 1; i < pt.size(); i++) {
      if (k < pt[i] - pt[i - 1] - 1) k = pt[i] - pt[i - 1] - 1;
    }
  }
  ans = mi * n + k;
  cout << ans << endl;
}
