#include <bits/stdc++.h>
using namespace std;
vector<int> all;
void build(int n) {
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      all.push_back(i);
    }
  if (n != 1) all.push_back(n);
}
int a[1000020];
long long ans[1000200];
long long res[1000200][3];
int n;
long long A, B, RES;
void solve(int x) {
  for (int i = 1; i <= n; i++) {
    if (a[i] % x == 0) {
      ans[i] = 0;
      continue;
    }
    if ((a[i] - 1) % x == 0) {
      ans[i] = B;
      continue;
    }
    if ((a[i] + 1) % x == 0) {
      ans[i] = B;
      continue;
    }
    ans[i] = -1;
  }
  bool f = 0;
  for (int i = 1; i <= n; i++)
    res[i][2] = res[i][1] = res[i][0] = 10000000000000000LL;
  for (int i = 1; i <= n; i++) {
    res[i - 1][2] = min(res[i - 1][2], res[i - 1][1]);
    if (ans[i] != -1) {
      res[i][0] = min(res[i][0], res[i - 1][0] + ans[i]);
      res[i][2] = min(res[i][2], res[i - 1][2] + ans[i]);
    }
    res[i][1] = res[i - 1][1] + A;
    if (i != 1 && res[i - 1][0] + A <= res[i][1]) f = 1;
    if (res[i - 1][0] + A < res[i][1]) res[i][1] = res[i - 1][0] + A;
  }
  long long ans = min(res[n][2], res[n][0]);
  if (f) ans = min(ans, res[n][1]);
  RES = min(RES, ans);
}
int main() {
  cin >> n >> A >> B;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  build(a[1]);
  build(a[1] + 1);
  build(a[1] - 1);
  build(a[n]);
  build(a[n] + 1);
  build(a[n] - 1);
  all.push_back(1);
  sort(all.begin(), all.end());
  RES = 10000000000000000LL;
  for (int i = 1; i < all.size(); i++)
    if (all[i] != all[i - 1]) solve(all[i]);
  cout << RES << endl;
}
