#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int N = 1e5 + 1;
bool prime[N];
map<int, int> M;
int A[10 * N];
long long dp[10 * N][3];
int cur_prime, n, a, b;
long long solve(int ind, int flag) {
  if (ind == 1) {
    long long ret;
    if (flag == 0) {
      if (A[ind] % cur_prime == 0)
        ret = 0;
      else if ((A[ind] + 1) % cur_prime == 0 || (A[ind] - 1) % cur_prime == 0)
        ret = (long long)b;
      else
        ret = (long long)1e16;
    } else if (flag == 1) {
      ret = (long long)a;
    } else {
      ret = (long long)a;
    }
    return ret;
  }
  if (dp[ind][flag] != -1) return dp[ind][flag];
  long long& ret = dp[ind][flag];
  ret = LLONG_MAX;
  if (flag == 0) {
    if (A[ind] % cur_prime == 0) {
      ret = solve(ind - 1, 0);
    } else if ((A[ind] + 1) % cur_prime == 0 || (A[ind] - 1) % cur_prime == 0) {
      ret = b + solve(ind - 1, 0);
    } else {
      ret = (long long)1e16;
    }
  } else if (flag == 1) {
    ret = min(solve(ind - 1, 0) + a, solve(ind - 1, 1) + a);
  } else {
    ret = min(ret, a + solve(ind - 1, 0));
    ret = min(ret, a + solve(ind - 1, 1));
    long long ty;
    if (A[ind] % cur_prime == 0)
      ty = 0;
    else if ((A[ind] + 1) % cur_prime == 0 || (A[ind] - 1) % cur_prime == 0)
      ty = b;
    else
      ty = (long long)1e16;
    ret = min(ret, ty + solve(ind - 1, 2));
  }
  return ret;
}
void seive() {
  for (int i = 2; i < N; i++) prime[i] = true;
  for (int i = 2; i * i < N; i++) {
    if (prime[i]) {
      for (int j = 2 * i; j < N; j += i) {
        prime[j] = false;
      }
    }
  }
}
int main() {
  seive();
  scanf("%d", &n);
  scanf("%d", &a);
  scanf("%d", &b);
  for (int i = 1; i < n + 1; i++) {
    scanf("%d", &A[i]);
  }
  if (n == 1) {
    printf("%d\n", 0);
    return 0;
  }
  vector<int> cand;
  cand.push_back(A[1]);
  cand.push_back(A[1] + 1);
  cand.push_back(A[1] - 1);
  cand.push_back(A[n]);
  cand.push_back(A[n] + 1);
  cand.push_back(A[n] - 1);
  for (int x : cand) {
    if (x == 1) continue;
    for (int i = 1; i < N; i++) {
      if (prime[i] && x % i == 0) {
        M[i];
        while (x % i == 0) x /= i;
      }
    }
    if (x > 1) M[x];
  }
  long long ans = LLONG_MAX;
  for (auto itr = M.begin(); itr != M.end(); ++itr) {
    memset(dp, -1, sizeof(dp));
    cur_prime = itr->first;
    ans = min(ans, min(solve(n, 0), min(solve(n, 1), solve(n, 2))));
  }
  printf("%lld\n", ans);
  return 0;
}
