#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e9;
const long long linf = 1e18;
long long powm(long long a, long long p, long long m) {
  long long r = 1 % m;
  while (p) {
    if (p & 1) r = r * a % m;
    p >>= 1;
    a = a * a % m;
  }
  return r;
}
int v[1000000];
set<int> var;
void fact(int x) {
  for (int i = 2; i * i <= x; ++i)
    for (; x % i == 0; x /= i) var.insert(i);
  if (x > 1) var.insert(x);
}
int main() {
  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 0; i < n; ++i) scanf("%d", v + i);
  for (int i = -1; i < 2; ++i) {
    fact(v[0] + i);
    fact(v[n - 1] + i);
  }
  vector<int> s(var.begin(), var.end());
  vector<vector<long long> > dp(3, vector<long long>(s.size(), 0));
  for (int i = 0; i < n; ++i) {
    vector<vector<long long> > tmp(3, vector<long long>(s.size(), linf));
    for (int j = 0; j < s.size(); ++j)
      for (int k = 0; k < 3; ++k)
        if (dp[k][j] < linf) {
          for (int d = -1; d < 2; ++d)
            if ((v[i] + d) % s[j] == 0) {
              if (k == 0 || k == 2)
                tmp[k][j] = min(tmp[k][j], dp[k][j] + abs(d) * b);
              if (k == 1) tmp[2][j] = min(tmp[2][j], dp[k][j] + abs(d) * b);
            }
          if (k < 2) tmp[1][j] = min(tmp[1][j], dp[k][j] + a);
        }
    dp = tmp;
  }
  long long ans = 1ll * (n - 1) * a;
  for (int j = 0; j < s.size(); ++j)
    for (int k = 0; k < 3; ++k) ans = min(ans, dp[k][j]);
  cout << ans << endl;
  return 0;
}
