#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
const long long inf = 1e15;
int n;
long long a, b, costa, costb, num[maxn], cost[maxn], dp[maxn][3];
vector<long long> G;
void pri(long long num) {
  for (long long i = 2; i * i <= num; i++) {
    if ((num % i) == 0) G.push_back(i);
    while (num % i == 0) num /= i;
  }
  if (num > 1) G.push_back(num);
}
int main() {
  while (scanf("%d%I64d%I64d", &n, &costa, &costb) == 3) {
    memset(num, 0, sizeof(num));
    memset(cost, 0, sizeof(cost));
    memset(dp, 0, sizeof(dp));
    G.clear();
    for (int i = 1; i <= n; i++) scanf("%I64d", &num[i]);
    for (int i = -1; i <= 1; i++) {
      if (num[1] + i > 1) pri(num[1] + i);
      if (num[n] + i > 1) pri(num[n] + i);
    }
    sort(G.begin(), G.end());
    int len = G.size();
    long long res = inf;
    for (int i = 0; i < len; i++) {
      for (int j = 1; j <= n; j++)
        if ((num[j] - 1) % G[i] == 0 || (num[j] + 1) % G[i] == 0)
          cost[j] = costb;
        else if (num[j] % G[i] == 0)
          cost[j] = 0;
        else
          cost[j] = inf;
      for (int j = 1; j <= n; j++) {
        dp[j][0] = dp[j - 1][0] + cost[j];
        if (dp[j][0] > inf) dp[j][0] = inf;
        dp[j][1] = min(dp[j - 1][0], dp[j - 1][1]) + costa;
        if (dp[j][1] > inf) dp[j][1] = inf;
        dp[j][2] = min(dp[j - 1][1], dp[j - 1][2]) + cost[j];
        if (dp[j][2] > inf) dp[j][2] = inf;
      }
      res = min(res, min(dp[n][0], min(dp[n][1], dp[n][2])));
    }
    cout << res << endl;
  }
  return 0;
}
