#include <bits/stdc++.h>
using namespace std;
long long inf = 1e18;
int MAX_N = 1000005;
int n;
long long a, b;
vector<int> v;
long long cost = inf;
vector<int> soort;
set<int> pf;
vector<vector<long long> > dp(MAX_N, vector<long long>(3, inf));
void calc_pf(int a) {
  for (int i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      pf.insert(i);
      while (a % i == 0) {
        a /= i;
      }
    }
  }
  if (a != 1) {
    pf.insert(a);
  }
}
void calc(int num) {
  int first_idx = MAX_N;
  int second_idx = -1;
  for (int i = 0; i < n; i++) {
    if (v[i] % num == 0) {
      soort[i] = 0;
    } else if (((v[i] + 1) % num == 0) || ((v[i] - 1) % num == 0)) {
      soort[i] = 1;
    } else {
      soort[i] = 2;
      first_idx = min(first_idx, i);
      second_idx = max(second_idx, i);
    }
  }
  if (soort[0] == 0) {
    dp[0][0] = 0;
  } else if (soort[0] == 1) {
    dp[0][0] = b;
  } else {
    dp[0][0] = inf;
  }
  dp[0][1] = a;
  dp[0][2] = inf;
  for (int i = 1; i < n; i++) {
    if (first_idx <= i && i <= second_idx) {
      dp[i][0] = inf;
      dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + a;
      dp[i][2] = inf;
    } else {
      if (soort[i] == 0) {
        dp[i][0] = dp[i - 1][0];
        dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]);
      } else {
        dp[i][0] = dp[i - 1][0] + b;
        dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]) + b;
      }
      dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + a;
    }
  }
  cost = min(cost, min(dp[n - 1][0], min(dp[n - 1][1], dp[n - 1][2])));
}
int main() {
  scanf("%d %I64d %I64d", &n, &a, &b);
  for (int i = 0; i < n; i++) {
    int tmp;
    scanf("%d", &tmp);
    v.push_back(tmp);
  }
  if (n == 1) {
    printf("0\n");
    return 0;
  }
  for (int i = 0; i < n; i++) {
    soort.push_back(0);
  }
  for (int i = -1; i <= 1; i++) {
    calc_pf(v[0] + i);
    calc_pf(v[n - 1] + i);
  }
  for (set<int>::iterator it = pf.begin(); it != pf.end(); it++) {
    calc(*it);
  }
  printf("%I64d\n", cost);
  return 0;
}
