#include <bits/stdc++.h>
using namespace std;
template <class T1>
void deb(T1 e) {
  cout << e << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
long long arr[400010];
vector<long long> pos;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long i, j, test;
  long long ans = 0, n, mini;
  mini = 1ll << 60;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> arr[i];
    arr[i + n] = arr[i];
    mini = min(arr[i], mini);
  }
  long long m = 2ll * n;
  for (i = 1; i <= m; i++)
    if (arr[i] == mini) pos.push_back(i);
  long long temp;
  for (i = 0; i < (int)pos.size(); i++) {
    if (pos[i] > n) break;
    temp = arr[pos[i]] * n;
    if (pos[i + 1] < pos[i] + n)
      temp += (pos[i + 1] - pos[i] - 1);
    else
      temp += (n - 1);
    ans = max(ans, temp);
  }
  deb(ans);
  return 0;
}
