#include <bits/stdc++.h>
using namespace std;
bool cmp(const pair<pair<int, int>, pair<int, int> >& p1,
         const pair<pair<int, int>, pair<int, int> >& p2) {
  if (p1.first.first / 317 != p2.first.first / 317)
    return p1.first.first / 317 < p2.first.first / 317;
  return p1.first.second < p2.first.second;
}
int n;
long long int a, b;
vector<int> v;
int type = 0;
int factor = 0;
long long int visited[1000005][3], mem[1000005][3];
long long int sol(int idx, int check) {
  if (idx == n) return 0;
  if (visited[idx][check] == type) return mem[idx][check];
  visited[idx][check] = type;
  long long int ans = 1000000000000000000ll;
  if (check == 0) {
    if (v[idx] % factor == 0) ans = min(ans, sol(idx + 1, 0));
    if ((v[idx] + 1) % factor == 0) ans = min(ans, sol(idx + 1, 0) + b);
    if ((v[idx] - 1) % factor == 0) ans = min(ans, sol(idx + 1, 0) + b);
    ans = min(ans, sol(idx + 1, 1) + a);
  }
  if (check == 1) {
    ans = min(ans, sol(idx + 1, 1) + a);
    ans = min(ans, sol(idx, 2));
  }
  if (check == 2) {
    if (v[idx] % factor == 0) ans = min(ans, sol(idx + 1, 2));
    if ((v[idx] + 1) % factor == 0) ans = min(ans, sol(idx + 1, 2) + b);
    if ((v[idx] - 1) % factor == 0) ans = min(ans, sol(idx + 1, 2) + b);
  }
  mem[idx][check] = ans;
  return ans;
}
long long int sol_help(int x) {
  long long int ans = 1000000000000000000ll;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      type++;
      factor = i;
      ans = min(ans, sol(0, 0));
      while (x % i == 0) x = x / i;
    }
  }
  if (x != 1) {
    type++;
    factor = x;
    ans = min(ans, sol(0, 0));
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  scanf("%I64d", &a);
  scanf("%I64d", &b);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    v.push_back(a);
  }
  long long int res = 1000000000000000000ll;
  res = min(res, sol_help(v[0]));
  res = min(res, sol_help(v[0] - 1));
  res = min(res, sol_help(v[0] + 1));
  res = min(res, sol_help(v[n - 1]));
  res = min(res, sol_help(v[n - 1] - 1));
  res = min(res, sol_help(v[n - 1] + 1));
  printf("%I64d\n", res);
  return 0;
}
