#include <bits/stdc++.h>
using namespace std;
int n, A, B;
int a[1000010];
bool vis[1000010];
vector<int> p;
void init() {
  for (int i = 2; i < 40000; i++) {
    if (vis[i]) continue;
    int x = i * 2;
    while (x < 40000) {
      vis[x] = true;
      x += i;
    }
  }
  for (int i = 2; i < 40000; i++) {
    if (!vis[i]) p.push_back(i);
  }
}
long long dp[1000010][3];
long long getcost(int x, int y) {
  long long inf = (long long)n * (1e9);
  if (x % y == 0) return 0;
  if ((x + 1) % y == 0 || (x - 1) % y == 0) return B;
  return inf;
}
long long solve(int prime) {
  long long inf = (long long)n * (1e9);
  dp[1][0] = getcost(a[1], prime);
  dp[1][1] = A;
  dp[1][2] = inf;
  for (int i = 2; i <= n; i++) {
    dp[i][0] = min(inf, getcost(a[i], prime) + dp[i - 1][0]);
    dp[i][1] = min(inf, min(dp[i - 1][0], dp[i - 1][1]) + A);
    dp[i][2] = min(inf, min(dp[i - 1][2], dp[i - 1][1]) + getcost(a[i], prime));
  }
  return min(dp[n][0], min(dp[n][1], dp[n][2]));
}
int main() {
  init();
  scanf("%d%d%d", &n, &A, &B);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  int op[6] = {0, -1, 1, 0, -1, 1};
  int num[6] = {a[1], a[1], a[1], a[n], a[n], a[n]};
  long long ans = -1;
  for (int i = 0; i < 6; i++) {
    int x = op[i] + num[i], len = p.size();
    for (int j = 0; j < len; j++) {
      if (x == 1) break;
      if (x % p[j] == 0) {
        while (x % p[j] == 0) x /= p[j];
        long long tmp = solve(p[j]);
        if (ans == -1 || ans > tmp) ans = tmp;
      }
    }
    if (x != 1) {
      long long tmp = solve(x);
      if (ans == -1 || ans > tmp) ans = tmp;
    }
  }
  cout << ans << endl;
  return 0;
}
