#include <bits/stdc++.h>
using namespace std;
double PI = 2 * acos(0);
std::vector<int> vi;
int n;
long long arr[200005];
int main(int argc, char const *argv[]) {
  cin >> n;
  long long minimun = 1e9, ans = -1, a;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    minimun = min(arr[i], minimun);
  }
  for (int i = 0; i < 2 * n; i++) {
    arr[i % n] > minimun ? a++ : a = 0;
    ans = max(a, ans);
  }
  cout << ans + minimun * n;
  return 0;
}
