#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
const long long INF = 1e17;
vector<int> div1[3], divn[3];
long long n, t[N], a, b;
long long dp[N][2][3];
vector<int> divisor(int x) {
  int i = 2;
  vector<int> ans;
  while (i * i <= x) {
    if (x % i == 0) {
      ans.push_back(i);
      while (x % i == 0) x /= i;
    }
    i++;
  }
  if (x != 1) ans.push_back(x);
  return ans;
}
void Init() {
  div1[0] = divisor(t[1] - 1);
  div1[1] = divisor(t[1]);
  div1[2] = divisor(t[1] + 1);
  divn[0] = divisor(t[n] - 1);
  divn[1] = divisor(t[n]);
  divn[2] = divisor(t[n] + 1);
}
long long Solve(int div, int cp) {
  for (int k = 1; k <= n; k++)
    for (int i = 0; i <= 1; i++)
      for (int j = 0; j <= 2; j++) dp[k][i][j] = INF;
  dp[1][0][0] = 0;
  for (int i = 2; i <= n; i++)
    for (int j = 0; j <= 1; j++) {
      if (t[i] % div)
        dp[i][j][0] = INF;
      else
        dp[i][j][0] =
            min(dp[i - 1][j][1], min(dp[i - 1][j][0], dp[i - 1][j][2]));
      if ((t[i] + 1) % div == 0 || (t[i] - 1) % div == 0)
        dp[i][j][1] =
            b + min(dp[i - 1][j][0], min(dp[i - 1][j][1], dp[i - 1][j][2]));
      if (j == 0)
        dp[i][j][2] = INF;
      else
        dp[i][j][2] = a + min(min(dp[i - 1][j - 1][0], dp[i - 1][j - 1][1]),
                              dp[i - 1][j][2]);
    }
  long long ans = INF;
  for (int i = 0; i <= 1; i++)
    for (int j = 0; j <= 2; j++) ans = min(ans, dp[n][i][j]);
  ans += cp;
  return ans;
}
long long Solve2(int div, int cp) {
  for (int k = 1; k <= n; k++)
    for (int i = 0; i <= 1; i++)
      for (int j = 0; j <= 2; j++) dp[k][i][j] = INF;
  dp[0][0][0] = 0;
  for (int i = 1; i <= n - 1; i++)
    for (int j = 0; j <= 1; j++) {
      if (t[i] % div)
        dp[i][j][0] = INF;
      else
        dp[i][j][0] =
            min(dp[i - 1][j][1], min(dp[i - 1][j][0], dp[i - 1][j][2]));
      if ((t[i] + 1) % div == 0 || (t[i] - 1) % div == 0)
        dp[i][j][1] =
            b + min(dp[i - 1][j][0], min(dp[i - 1][j][1], dp[i - 1][j][2]));
      if (j == 0)
        dp[i][j][2] = INF;
      else
        dp[i][j][2] = a + min(min(dp[i - 1][j - 1][0], dp[i - 1][j - 1][1]),
                              dp[i - 1][j][2]);
    }
  long long ans = INF;
  for (int i = 0; i <= 1; i++)
    for (int j = 0; j <= 2; j++) ans = min(ans, dp[n - 1][i][j]);
  ans += cp;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) cin >> t[i];
  Init();
  long long res = INF;
  for (int i = 0; i <= 2; i++) {
    int cp;
    if (i == 1)
      cp = 0;
    else
      cp = b;
    for (int j = 0; j < div1[i].size(); j++)
      res = min(res, Solve(div1[i][j], cp));
  }
  for (int i = 0; i <= 2; i++) {
    int cp;
    if (i == 1)
      cp = 0;
    else
      cp = b;
    for (int j = 0; j < divn[i].size(); j++)
      res = min(res, Solve2(divn[i][j], cp));
  }
  cout << res;
  return 0;
}
