#include <bits/stdc++.h>
using namespace std;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, -1, 1};
const double eps = 1e-9;
const int INF = 0x7FFFFFFF;
const long long INFLL = 0x7FFFFFFFFFFFFFFFLL;
const double pi = acos(-1);
template <class T>
T take(queue<T> &O) {
  T tmp = O.front();
  O.pop();
  return tmp;
}
template <class T>
T take(stack<T> &O) {
  T tmp = O.top();
  O.pop();
  return tmp;
}
template <class T>
T take(priority_queue<T> &O) {
  T tmp = O.top();
  O.pop();
  return tmp;
}
template <class T>
inline void getint(T &num) {
  bool neg = 0;
  num = 0;
  char c;
  while ((c = getchar_unlocked()) && (!isdigit(c) && c != '-'))
    ;
  if (c == '-') {
    neg = 1;
    c = getchar_unlocked();
  }
  do num = num * 10 + c - '0';
  while ((c = getchar_unlocked()) && isdigit(c));
  if (neg) num = -num;
}
template <class T>
inline bool inRange(T z, T a, T b) {
  return a <= z && z <= b;
}
void OPEN(string in = "input.txt", string out = "output.txt") {
  freopen(in.c_str(), "r", stdin);
  freopen(out.c_str(), "w", stdout);
  return;
}
bitset<32768> isp;
vector<int> primes, used;
int cnt[32768];
int arr[1000005], n;
long long ans, a, b;
inline void proc(int x, int val) {
  for (int(i) = (0), _t = ((int)primes.size()); i < (_t); ++(i)) {
    const int &p = primes[i];
    if (x % p == 0) {
      cnt[i] |= val;
      while (x % p == 0) x /= p;
    }
  }
  if (x != 1LL) used.push_back(x);
  return;
}
long long pcost[1000005];
inline void coba(int p) {
  long long res = INFLL;
  long long cost = 0LL;
  fill(pcost, pcost + n, INFLL);
  pcost[n] = a * n;
  for (int(i) = (n - 1), _t = (0); i >= (_t); --(i)) {
    if (arr[i] % p == 0)
      ;
    else if ((arr[i] - 1) % p == 0 || (arr[i] + 1) % p == 0)
      cost += b;
    else
      break;
    pcost[i] = a * i + cost;
    res = min(res, pcost[i]);
  }
  for (int(i) = (n - 1), _t = (0); i >= (_t); --(i))
    pcost[i] = min(pcost[i], pcost[i + 1]);
  cost = 0LL;
  for (int(i) = (0), _t = (n); i < (_t); ++(i)) {
    if (arr[i] % p == 0)
      ;
    else if ((arr[i] - 1) % p == 0 || (arr[i] + 1) % p == 0)
      cost += b;
    else
      break;
    res = min(res, cost + pcost[i + 1] - a * (i + 1));
  }
  ans = min(ans, res);
}
int main(int argc, const char *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  isp.set();
  for (int(i) = (2), _t = (32768); i < (_t); ++(i))
    if (isp.test(i)) {
      primes.push_back(i);
      long long c = 1LL * i * i;
      while (c < 32768) {
        isp.set(c, 0);
        c += i;
      }
    }
  ans = INFLL;
  cin >> n >> a >> b;
  for (int(i) = (0), _t = (n); i < (_t); ++(i)) cin >> arr[i];
  for (int(i) = (-1), _t = (1); i <= (_t); ++(i)) {
    proc(arr[0] + i, 1);
    proc(arr[n - 1] + i, 2);
  }
  for (int(i) = (0), _t = ((int)primes.size()); i < (_t); ++(i))
    if (cnt[i]) used.push_back(primes[i]);
  for (const auto &p : used) coba(p);
  cout << ans << "\n";
  return 0;
}
