#include <bits/stdc++.h>
using namespace std;
const int MOD9 = 1e9 + 7;
const int MOD91 = 1e9 + 9;
const long long MOD12 = 1e12 + 39LL;
const long long MOD15 = 1e15 + 37LL;
const long long INF = 1e16;
const int base = 1e9;
const int MAX = 2e6;
const long double EPS = 1e-10;
set<long long> prime;
void fp(long long x) {
  long long i = 2;
  prime.insert(i);
  while (x > 1 && i <= sqrt(x)) {
    if (x % i == 0) prime.insert(i);
    while (x % i == 0) {
      x /= i;
    }
    i++;
  }
  if (x != 1) {
    prime.insert(x);
  }
}
long long dp[3][MAX];
long long a, b, n;
long long c[MAX];
int main() {
  cin >> n >> a >> b;
  for (int i = (0); i < (n); ++i) {
    scanf("%I64d", &c[i]);
  }
  long long ans = INF;
  fp(c[0]);
  fp(c[0] - 1);
  fp(c[0] + 1);
  fp(c[n - 1]);
  fp(c[n - 1] - 1);
  fp(c[n - 1] + 1);
  for (auto &p : prime) {
    for (int i = (0); i < (n + 1); ++i) {
      for (int j = (0); j < (3); ++j) {
        dp[j][i] = INF;
      }
    }
    if (c[0] % p == 0) {
      dp[0][0] = 0;
    } else if ((c[0] + 1) % p == 0 || (c[0] - 1) % p == 0) {
      dp[0][0] = b;
    }
    dp[1][0] = a;
    for (int i = 0; i < n - 1; ++i) {
      if (c[i + 1] % p == 0) {
        dp[0][i + 1] = min(dp[0][i + 1], dp[0][i]);
        dp[2][i + 1] = min(dp[2][i + 1], dp[2][i]);
        dp[2][i + 1] = min(dp[2][i + 1], dp[1][i]);
      }
      if ((c[i + 1] + 1) % p == 0) {
        dp[0][i + 1] = min(dp[0][i + 1], dp[0][i] + b);
        dp[2][i + 1] = min(dp[2][i + 1], dp[2][i] + b);
        dp[2][i + 1] = min(dp[2][i + 1], dp[1][i] + b);
      }
      if ((c[i + 1] - 1) % p == 0) {
        dp[0][i + 1] = min(dp[0][i + 1], dp[0][i] + b);
        dp[2][i + 1] = min(dp[2][i + 1], dp[2][i] + b);
        dp[2][i + 1] = min(dp[2][i + 1], dp[1][i] + b);
      }
      dp[1][i + 1] = min(dp[1][i + 1], min(dp[1][i] + a, dp[0][i] + a));
    }
    for (int i = 0; i < 3; ++i) {
      ans = min(ans, dp[i][n - 1]);
    }
  }
  cout << ans;
  return 0;
}
