#include <bits/stdc++.h>
long long mpow(long long a, long long n, long long mod) {
  long long ret = 1;
  long long b = a;
  while (n) {
    if (n & 1) ret = (ret * b) % mod;
    b = (b * b) % mod;
    n >>= 1;
  }
  return (long long)ret;
}
using namespace std;
set<int> poss;
bool chk[(int)(4e4 + 25)];
vector<int> prim;
int a[1000005];
long long dp[1000005][3];
void sieve() {
  for (int i = 2; i < (int)(4e4 + 25); i++) {
    if (chk[i]) continue;
    prim.push_back(i);
    for (int j = 2 * i; j < (int)(4e4 + 25); j += i) {
      chk[j] = 1;
    }
  }
}
void make(int x) {
  if (x == 0) {
    return;
  }
  for (int i = 0; i < prim.size(); i++) {
    int valid = 0;
    while (x % prim[i] == 0) {
      x /= prim[i];
      valid = 1;
    }
    if (valid) {
      poss.insert(prim[i]);
    }
  }
  if (x != 1) {
    poss.insert(x);
  }
}
void solve() {
  int n, A, B;
  scanf("%d", &n);
  scanf("%d", &A);
  scanf("%d", &B);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  long long vhigh = (1ll << 60);
  long long ans = vhigh;
  make(a[1]);
  make(a[1] - 1);
  make(a[1] + 1);
  make(a[n] - 1);
  make(a[n]);
  make(a[n] + 1);
  for (set<int>::iterator it = poss.begin(); it != poss.end(); it++) {
    int p = *it;
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i] % p == 0) {
        dp[i][0] = dp[i - 1][0];
        dp[i][1] = min(dp[i - 1][1], dp[i][0]) + A;
        dp[i][2] = min(dp[i][1], dp[i - 1][2]);
      } else if ((a[i] + 1) % p == 0 || (a[i] - 1) % p == 0) {
        dp[i][0] = dp[i - 1][0] + B;
        dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + A;
        dp[i][2] = min(dp[i][1], dp[i - 1][2] + B);
      } else {
        dp[i][0] = vhigh;
        dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + A;
        dp[i][2] = dp[i][1];
      }
    }
    ans = min(ans, min(dp[n][0], dp[n][2]));
  }
  cout << ans;
}
int main() {
  int t = 1;
  sieve();
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
