#include <bits/stdc++.h>
using namespace std;
int n, arr[200009], mini, cnt = 0, tmp = 0;
vector<int> idx;
bool found = false;
long long ans;
int main() {
  scanf("%d", &n);
  scanf("%d", &arr[0]);
  mini = arr[0];
  for (int i = 1; i < n; i++) {
    scanf("%d", &arr[i]);
    mini = min(mini, arr[i]);
  }
  for (int i = 0; i < n; i++) {
    if (arr[i] == mini) {
      idx.push_back(i);
    } else {
      cnt++;
    }
  }
  ans = (long long)n * mini;
  if (cnt == n) {
    printf("%lld\n", ans);
  } else if (cnt == n - 1) {
    printf("%lld\n", ans + n - 1);
  } else {
    tmp = idx[0] + n - idx[idx.size() - 1] - 1;
    for (int i = 0; i < idx.size() - 1; i++) {
      tmp = max(tmp, idx[i + 1] - idx[i] - 1);
    }
    ans += tmp;
    cout << ans << endl;
  }
  return 0;
}
