#include <bits/stdc++.h>
using namespace std;
map<long long int, long long int> m[2], m2, mc[1000];
map<string, int> ms;
pair<int, pair<int, pair<int, int> > > pa;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long int n;
  cin >> n;
  long long int a[n + 2];
  for (int i = 0; i < n; ++i) cin >> a[i];
  long long int b[2 * n + 2];
  for (int i = 0; i < n; ++i) b[i] = a[i];
  for (int i = n; i < 2 * n; ++i) b[i] = a[i - n];
  sort(a, a + n);
  for (int i = 0; i < 2 * n; ++i) b[i] -= a[0];
  long long int ct = 0, ans = 0;
  for (int i = 0; i < 2 * n; ++i) {
    if (b[i] > 0)
      ct++, ans = max(ct, ans);
    else
      ct = 0;
  }
  ans += (a[0]) * n;
  cout << ans << endl;
}
