#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, j, k, m;
  while (cin >> n) {
    vector<long long> v;
    long long min = INT_MAX;
    for (i = 0; i < n; i++) {
      cin >> m;
      v.push_back(m);
      if (m <= min) {
        min = m;
        j = i + 1;
      }
    }
    long long l = 0;
    k = 0;
    long long p = 1;
    long long s;
    for (i = 0; i < n; i++) {
      if (v[i] == min) {
        if (p == 1) {
          s = i;
          p = 2;
        }
        if (k >= l) {
          l = k;
        }
        k = 0;
      } else {
        k++;
      }
    }
    if (l < k + s) {
      l = k + s;
    }
    cout << n * min + l << endl;
  }
  return 0;
}
