#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
int n, A, B, a[maxn];
long long dp[maxn][3];
long long solve(int x, int y) {
  if (x == 1) return LLONG_MAX;
  vector<int> facs;
  for (int i = 2; i * i <= x; ++i) {
    if (x % i == 0) {
      facs.push_back(i);
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) facs.push_back(x);
  long long ans = LLONG_MAX;
  for (int j = 0; j < facs.size(); ++j) {
    memset(dp, 0x3f, sizeof(dp));
    dp[1][0] = y;
    for (int i = 2; i <= n; ++i) {
      if ((a[i] - 1) % facs[j] == 0) {
        dp[i][0] = min(dp[i][0], dp[i - 1][0] + B);
        dp[i][2] = min(dp[i][2], min(dp[i - 1][1], dp[i - 1][2]) + B);
      }
      if ((a[i] + 1) % facs[j] == 0) {
        dp[i][0] = min(dp[i][0], dp[i - 1][0] + B);
        dp[i][2] = min(dp[i][2], min(dp[i - 1][1], dp[i - 1][2]) + B);
      }
      if (a[i] % facs[j] == 0) {
        dp[i][0] = min(dp[i][0], dp[i - 1][0]);
        dp[i][2] = min(dp[i][2], min(dp[i - 1][1], dp[i - 1][2]));
      }
      dp[i][1] = min(dp[i][1], min(dp[i - 1][0], dp[i - 1][1]) + A);
    }
    ans = min(ans, dp[n][0]);
    ans = min(ans, dp[n][1]);
    ans = min(ans, dp[n][2]);
  }
  return ans;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  scanf("%d%d%d", &n, &A, &B);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  long long ans = LLONG_MAX;
  ans = min(ans, solve(a[1] - 1, B));
  ans = min(ans, solve(a[1], 0));
  ans = min(ans, solve(a[1] + 1, B));
  reverse(a + 1, a + 1 + n);
  ans = min(ans, solve(a[1] - 1, B));
  ans = min(ans, solve(a[1], 0));
  ans = min(ans, solve(a[1] + 1, B));
  printf("%I64d\n", ans);
  return 0;
}
