#include <bits/stdc++.h>
using namespace std;
int a[200005], v[200005];
int main() {
  int n, minm, maxm, k, f;
  long long int cnt;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  minm = a[0];
  for (int i = 1; i < n; i++) {
    minm = min(minm, a[i]);
  }
  cnt = (long long int)minm * (long long int)n;
  k = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == minm) {
      k++;
    } else {
      v[k]++;
    }
  }
  if (k > 0) v[0] += v[k];
  maxm = v[0];
  for (int i = 0; i < k; i++) maxm = max(maxm, v[i]);
  cnt += (long long int)maxm;
  cout << cnt;
  return 0;
}
