#include <bits/stdc++.h>
using namespace std;
int a[200010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  int min_a = *min_element(a + 1, a + 1 + n);
  long long ans = (long long)min_a * n;
  int cnt = 0, max_cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] - min_a > 0)
      cnt++;
    else {
      max_cnt = max(max_cnt, cnt);
      cnt = 0;
    }
  }
  max_cnt = max(max_cnt, cnt);
  ans += max_cnt;
  long long ans2 = (long long)min_a * n;
  for (int i = 1; i <= n; i++)
    if (a[i] - min_a > 0)
      ans2++;
    else
      break;
  for (int i = n; i >= 1; i--)
    if (a[i] - min_a > 0)
      ans2++;
    else
      break;
  printf("%lld\n", max(ans, ans2));
  return 0;
}
