#include <bits/stdc++.h>
using namespace std;
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e6 + 9, M = 3e4 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const long long inf = 1e18;
long long arr[N], mem[N][4], a, b;
int n, val;
set<int> primes;
vector<int> vec;
void factorize(int n) {
  if (!(n & 1)) primes.insert(2);
  while (!(n & 1)) n >>= 1;
  for (long long i = 3; i * i <= n; i += 2) {
    if (n % i == 0) primes.insert(i);
    while (n % i == 0) n /= i;
  }
  if (n > 1) primes.insert(n);
}
long long solve(int x, int state) {
  if (x == n) return 0;
  long long& ret = mem[x][state];
  if (~ret) return ret;
  ret = inf;
  if (state == 0) {
    if (arr[x] % val == 0) ret = min(ret, solve(x + 1, state));
    if (((arr[x] + 1) % val == 0) || ((arr[x] - 1) % val == 0))
      ret = min(ret, solve(x + 1, state) + b);
    ret = min(ret, solve(x + 1, 1) + a);
    ret = min(ret, solve(x + 1, 2) + a);
  } else if (state == 1) {
    ret = min(ret, solve(x + 1, 1) + a);
    ret = min(ret, solve(x + 1, 2) + a);
  } else {
    if (arr[x] % val == 0) ret = min(ret, solve(x + 1, state));
    if (((arr[x] + 1) % val == 0) || ((arr[x] - 1) % val == 0))
      ret = min(ret, solve(x + 1, state) + b);
  }
  return ret;
}
int main() {
  cout << fixed << setprecision(0), ios::sync_with_stdio(false),
      cin.tie(nullptr), cout.tie(nullptr);
  cin >> n >> a >> b;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  for (int i = -1; i <= 1; ++i) {
    factorize(arr[0] + i);
    factorize(arr[n - 1] + i);
  }
  vec = vector<int>(primes.begin(), primes.end());
  long long ans = inf;
  for (int it : vec) {
    memset(mem, -1, sizeof(mem)), val = it;
    ans = min(ans, solve(0, 0));
  }
  cout << ans;
  return 0;
}
