#include <bits/stdc++.h>
using namespace std;
int a[410000];
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  int mn = 1100000000;
  int num = 0, m = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < mn) mn = a[i];
    a[i + n] = a[i];
  }
  int cur = 0;
  int ans = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (a[i] == mn) {
      ans = max(ans, cur);
      cur = 0;
    } else
      cur++;
  }
  cout << 1ll * mn * n + 1ll * ans << endl;
  return 0;
}
