#include <bits/stdc++.h>
using namespace std;
const int max_n = 1e6 + 5;
int minp[100005];
void sito() {
  for (int i = (0); i < (40000); ++i) minp[i] = i;
  for (int i = 2; i < 40000; i++) {
    if (minp[i] == i)
      for (int j = i * i; j < 40000; j += i) minp[j] = i;
  }
}
int dupa[max_n];
long long int cost[max_n][3];
long long int INF = 1e16;
int main() {
  sito();
  int(n);
  scanf("%d", &(n));
  ;
  long long int A, B;
  cin >> A >> B;
  vector<int>(v);
  for (int i = (0); i < ((n)); ++i) {
    int(a);
    scanf("%d", &(a));
    ;
    (v).push_back(a);
  };
  long long int ans = INF;
  for (int uu = (0); uu < (2); ++uu) {
    int x = v[0];
    vector<int> pos;
    for (int ux = (x - 1); ux < (x + 2); ++ux) {
      vector<int> pos2;
      for (int i = 2; i * i <= ux; i++) {
        if (ux % i == 0 && minp[i] == i) pos.push_back(i), pos2.push_back(i);
      }
      int zz = ux;
      for (__typeof((pos2).begin()) i = ((pos2).begin()); i != (pos2).end();
           ++i)
        zz = zz / (*i);
      if (zz > 1) pos.push_back(zz);
    }
    for (__typeof((pos).begin()) i = ((pos).begin()); i != (pos).end(); ++i) {
      int p = *i;
      cost[0][0] = (v[0] % p == 0) ? 0 : B;
      cost[0][1] = INF;
      cost[0][2] = INF;
      for (int j = (1); j < (n); ++j) {
        if (v[j] % p == 0) {
          cost[j][0] = cost[j - 1][0];
          cost[j][1] = min(cost[j - 1][0] + A, cost[j - 1][1] + A);
          cost[j][2] = min(cost[j - 1][1], cost[j - 1][2]);
        } else if ((v[j] - 1) % p == 0 || (v[j] + 1) % p == 0) {
          cost[j][0] = cost[j - 1][0] + B;
          cost[j][1] = min(cost[j - 1][0] + A, cost[j - 1][1] + A);
          cost[j][2] = min(cost[j - 1][2] + B, cost[j - 1][1] + B);
        } else {
          cost[j][0] = INF;
          cost[j][1] = min(cost[j - 1][0] + A, cost[j - 1][1] + A);
          cost[j][2] = INF;
        }
      }
      ans = min(ans, cost[n - 1][0]);
      ans = min(ans, cost[n - 1][1]);
      ans = min(ans, cost[n - 1][2]);
    }
    for (int i = 0; i < n - i - 1; i++) swap(v[i], v[n - 1 - i]);
  }
  printf("%I64d\n", ans);
}
