#include <bits/stdc++.h>
using namespace std;
const int nx[4] = {0, 0, 1, -1};
const int ny[4] = {1, -1, 0, 0};
const long long LINF = (long long)1e18;
const int INF = 1e9 + 7;
const int N = 1e6 + 1;
const double EPS = 1e-9, PI = 3.1415926;
int n, a, b;
long long ans = LINF;
int c[N];
long long dp[N][3];
vector<int> p;
inline void update(int x) {
  for (int i = 2; i * 1LL * i <= x; i++) {
    if (x % i == 0) {
      while (x % i == 0) x /= i;
      p.push_back(i);
    }
  }
  if (x > 1) p.push_back(x);
}
inline void calc(int gcd) {
  dp[0][1] = dp[0][2] = LINF;
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 3; j++) dp[i][j] = LINF;
  for (int i = 1; i <= n; i++) {
    for (int j = c[i] - 1; j < c[i] + 2; j++) {
      int cost = (j != c[i] ? b : 0);
      dp[i][1] = min(dp[i][1], min(dp[i - 1][1], dp[i - 1][0]) + cost + a);
      if (j % gcd == 0) {
        dp[i][0] = min(dp[i][0], dp[i - 1][0] + cost);
        dp[i][2] = min(dp[i][2],
                       min(dp[i][1], min(dp[i - 1][1], dp[i - 1][2])) + cost);
      } else {
        dp[i][2] = min(dp[i][2], dp[i - 1][1] + a + cost);
        dp[i][2] = min(dp[i][2], dp[i][1]);
      }
    }
  }
  for (int j = 0; j < 3; j++) ans = min(ans, dp[n][j]);
}
int main() {
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
  }
  for (int i = c[1] - 1; i <= c[1] + 1; i++) update(i);
  for (int i = c[n] - 1; i <= c[n] + 1; i++) update(i);
  sort(p.begin(), p.end());
  p.resize(unique(p.begin(), p.end()) - p.begin());
  for (auto it : p) calc(it);
  printf("%I64d\n", ans);
  return 0;
}
