#include <bits/stdc++.h>
using namespace std;
void getprime(int x, vector<int> &p) {
  for (int i = 2; (long long)i * i <= x; i++) {
    if (x % i == 0) {
      p.push_back(i);
    }
    while (x % i == 0) {
      x /= i;
    }
  }
  if (x != 1) {
    p.push_back(x);
  }
}
const int N = 1000010;
int n;
int A, B;
int a[N];
long long dp[N][3];
long long solve() {
  vector<int> p;
  getprime(a[1] - 1, p);
  getprime(a[1], p);
  getprime(a[1] + 1, p);
  getprime(a[n] - 1, p);
  getprime(a[n], p);
  getprime(a[n] + 1, p);
  sort(p.begin(), p.end());
  unique(p.begin(), p.end());
  long long ans = 1e18;
  for (int j = 0; j < p.size(); j++) {
    dp[0][0] = 0;
    dp[0][1] = 1e18;
    dp[0][2] = 1e18;
    for (int i = 1; i <= n; i++) {
      dp[i][0] = dp[i][1] = dp[i][2] = 1e18;
      if (a[i] % p[j] == 0) {
        dp[i][0] = dp[i - 1][0];
        dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]);
      } else if ((a[i] - 1) % p[j] == 0 || (a[i] + 1) % p[j] == 0) {
        dp[i][0] = dp[i - 1][0] + B;
        dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]) + B;
      }
      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() {
  while (cin >> n >> A >> B) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", a + i);
    }
    cout << solve() << endl;
  }
  return 0;
}
