#include <bits/stdc++.h>
using namespace std;
const long long MAXn = 1e6 + 10, INF = 1e18;
long long dp[MAXn][2][2], a, b, n, ar[MAXn], ans = INF;
long long calc(int prime) {
  for (int i = 0; i < MAXn; i++) {
    for (int j = 0; j < 2; j++) dp[i][j][0] = dp[i][j][1] = INF;
  }
  dp[0][1][1] = a;
  if ((ar[0] + 1) % prime == 0) dp[0][0][0] = b;
  if ((ar[0] - 1) % prime == 0) dp[0][0][0] = b;
  if (ar[0] % prime == 0) dp[0][0][0] = 0;
  for (int i = 1; i < n; i++) {
    if (ar[i] % prime == 0) {
      dp[i][0][1] = min(dp[i][0][1], min(dp[i - 1][0][1], dp[i - 1][1][1]));
      dp[i][0][0] = min(dp[i][0][0], dp[i - 1][0][0]);
    } else if ((ar[i] + 1) % prime == 0 || (ar[i] - 1) % prime == 0) {
      dp[i][0][1] = min(dp[i][0][1], min(dp[i - 1][0][1], dp[i - 1][1][1]) + b);
      dp[i][0][0] = min(dp[i][0][0], dp[i - 1][0][0] + b);
    }
    dp[i][1][1] = min(dp[i][1][1], min(dp[i - 1][0][0], dp[i - 1][1][1]) + a);
  }
  long long mn = INF;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) mn = min(dp[n - 1][i][j], mn);
  return mn;
}
void solve(int a) {
  for (long long i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      ans = min(ans, calc(i));
      while (a % i == 0) a /= i;
    }
  }
  if (a != 1) ans = min(ans, calc(a));
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) cin >> ar[i];
  for (int i = -1; i <= 1; i++) {
    solve(ar[0] + i);
    solve(ar[n - 1] + i);
  }
  cout << ans;
}
