#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)5E18;
int N, a[1000005], delta[3] = {-1, 0, 1};
long long A, B, dp[1000005][3];
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
int main() {
  cin >> N >> A >> B;
  for (int i = (1); i < (N + 1); i++) scanf("%d", a + i);
  set<int> ds;
  for (int t = (0); t < (2); t++) {
    int ix = t == 0 ? a[1] : a[N];
    for (int di = (0); di < (3); di++) {
      int x = ix + delta[di];
      for (int div = (2); div < (32000); div++) {
        if (div > x || x == 1) break;
        while (x % div == 0) {
          x /= div;
          ds.insert(div);
        }
      }
      if (x > 1) ds.insert(x);
    }
  }
  long long ans = INF;
  for (set<int>::iterator r = ds.begin(); r != ds.end(); r++) {
    int d = *r;
    for (int i = (0); i < (N + 1); i++)
      for (int s = (0); s < (3); s++) dp[i][s] = INF;
    dp[0][0] = 0;
    long long prev;
    for (int i = (1); i < (N + 1); i++) {
      for (int di = (0); di < (3); di++) {
        int x = a[i] + delta[di];
        if (gcd(x, d) % d) continue;
        long long cost = x == a[i] ? 0 : B;
        if ((prev = dp[i - 1][0]) != INF) dp[i][0] = min(dp[i][0], prev + cost);
        if ((prev = dp[i - 1][2]) != INF) dp[i][2] = min(dp[i][2], prev + cost);
        if ((prev = dp[i - 1][1]) != INF) dp[i][2] = min(dp[i][2], prev + cost);
      }
      if ((prev = dp[i - 1][0]) != INF) dp[i][1] = min(dp[i][1], prev + A);
      if ((prev = dp[i - 1][1]) != INF) dp[i][1] = min(dp[i][1], prev + A);
      for (int s = (0); s < (3); s++) ans = min(ans, dp[N][s]);
    }
  }
  cout << ans << endl;
  return 0;
}
