#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
vector<int> vp;
void deprime(int x) {
  for (int d = 2; (long long)d * d <= x; d++)
    if (x % d == 0) {
      vp.push_back(d);
      while (x % d == 0) x /= d;
    }
  if (x > 1) vp.push_back(x);
}
int a, b, c[1000055];
long long ans = (1LL << 60);
long long dp[1000055][3];
void cal(int p) {
  for (int(i) = 0; (i) < (int)(1000055); (i)++)
    for (int(j) = 0; (j) < (int)(3); (j)++) dp[i][j] = (1LL << 60);
  for (int(j) = 0; (j) < (int)(3); (j)++) dp[0][j] = 0;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    int con = 0;
    if (c[i] % p != 0) {
      if ((c[i] + 1) % p == 0 || (c[i] - 1) % p == 0)
        con = 1;
      else
        con = 2;
    }
    if (con == 0) {
      dp[i][0] = dp[i - 1][0];
      dp[i][1] = dp[i - 1][1] + a;
      dp[i][2] = dp[i - 1][2];
    } else {
      dp[i][1] = min(dp[i - 1][0] + a, dp[i - 1][1] + a);
      dp[i][2] = min(dp[i - 1][1] + a, dp[i - 1][0] + a);
      if (con == 1) {
        dp[i][0] = min(dp[i - 1][0] + b, dp[i][0]);
        dp[i][2] = min(dp[i - 1][2] + b, dp[i][2]);
      }
    }
  }
  for (int(j) = 0; (j) < (int)(3); (j)++) ans = min(ans, dp[n][j]);
}
void fmain() {
  scanf("%d%d%d", &n, &a, &b);
  for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%d", c + i);
  for (int i = -1; i <= 1; i++) {
    deprime(c[1] + i);
    deprime(c[n] + i);
  }
  int N = unique(vp.begin(), vp.end()) - vp.begin();
  for (int(i) = 0; (i) < (int)(N); (i)++) cal(vp[i]);
  printf("%lld\n", ans);
}
int main() {
  fmain();
  return 0;
}
