#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const long double LDINF = 1e20;
const double DINF = 1e20;
const long long LINF = (long long)1e18 + 5;
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
long long round(T x) {
  return x < 0 ? x - 0.5 : x + 0.5;
}
vector<int> my_merge(vector<int> a, vector<int> b) {
  for (auto x : b) {
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  return a;
}
vector<int> prime_factors(int x) {
  vector<int> p;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      p.push_back(i);
      while (x % i == 0) {
        x /= i;
      }
    }
  }
  if (x != 1) p.push_back(x);
  sort(p.begin(), p.end());
  return p;
}
const int N = (int)1e6 + 5;
int n, a, b;
int c[N];
long long cost[N], pref[N];
long long solve(int g) {
  for (int i = 1; i <= n; i++) {
    if (c[i] % g == 0)
      cost[i] = 0;
    else if ((c[i] - 1) % g == 0 || (c[i] + 1) % g == 0)
      cost[i] = b;
    else
      cost[i] = -1;
  }
  for (int i = 1; i <= n; i++) {
    pref[i] = pref[i - 1] + cost[i];
  }
  long long best = LINF;
  if (*min_element(cost + 1, cost + n + 1) != -1) best = 1LL * pref[n];
  long long minimal = 0;
  bool fl = true;
  int cnt = 0;
  for (int i = n; i >= 1; i--) {
    cnt += (cost[i] == -1 ? 1 : 0);
  }
  for (int i = 1; i < n; i++) {
    if (cost[i] == -1) cnt--;
    long long cur =
        cnt ? LINF : (minimal + 1LL * i * a + 1LL * (pref[n] - pref[i]));
    if (cur < best) best = cur;
    if (cost[i] == -1) fl = false;
    if (fl) minimal = min(minimal, 1LL * pref[i] - 1LL * i * a);
  }
  int i = n;
  for (int j = 1; j < n; j++) {
    if (cost[j] == -1) break;
    best = min(best,
               1LL * pref[j] + 1LL * (pref[n] - pref[i]) + 1LL * (i - j) * a);
  }
  return best;
}
int main() {
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%d", c + i);
  }
  vector<int> f = prime_factors(c[1]);
  f = my_merge(f, prime_factors(c[1] + 1));
  f = my_merge(f, prime_factors(c[1] - 1));
  f = my_merge(f, prime_factors(c[n]));
  f = my_merge(f, prime_factors(c[n] - 1));
  f = my_merge(f, prime_factors(c[n] + 1));
  long long result = 1LL * a * (n - 1);
  for (auto p : f) {
    result = min(result, solve(p));
  }
  cout << result << endl;
  return 0;
}
