#include <bits/stdc++.h>
using std::abs;
using std::bitset;
using std::cerr;
using std::cin;
using std::cout;
using std::deque;
using std::map;
using std::max;
using std::min;
using std::pair;
using std::queue;
using std::set;
using std::sort;
using std::string;
using std::swap;
using std::unordered_map;
using std::unordered_set;
using std::vector;
void init() {
  std::iostream::sync_with_stdio(0);
  cout << std::fixed;
  cout.precision(10);
  cerr << std::fixed;
  cerr.precision(10);
  srand(time(0));
}
const int MAXN = 1e6 + 1;
long long arr[MAXN];
long long dp[MAXN][3];
int n;
long long a, b;
const long long INF = 1e18;
vector<int> fact(int x) {
  vector<int> res;
  int k = x;
  for (int i = 2; i * i <= k; ++i)
    if (!(x % i)) {
      x /= i;
      res.push_back(i);
    }
  if (x > 1) res.push_back(x);
  return res;
}
long long solve(int p) {
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j < 3; ++j) dp[i][j] = INF;
  for (int i = 0; i < 3; ++i) dp[0][i] = 0;
  for (int i = 1; i <= n; ++i) {
    dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + a;
    if (arr[i] % p == 0) {
      dp[i][0] = dp[i - 1][0];
      dp[i][2] = min(dp[i - 1][2], dp[i - 1][1]);
    } else if ((arr[i] + 1) % p == 0 || (arr[i] - 1) % p == 0) {
      dp[i][0] = dp[i - 1][0] + b;
      dp[i][2] = min(dp[i - 1][2], dp[i - 1][1]) + b;
    }
  }
  long long ans = INF;
  for (int i = 0; i < 3; ++i) ans = min(ans, dp[n][i]);
  return ans;
}
int main() {
  init();
  cin >> n >> a >> b;
  for (int i = 1; i <= n; ++i) cin >> arr[i];
  set<int> ma;
  for (int i = -1; i <= 1; ++i) {
    vector<int> tmp;
    tmp = fact(arr[1] + i);
    for (auto j : tmp) ma.insert(j);
    tmp = fact(arr[n] + i);
    for (auto j : tmp) ma.insert(j);
  }
  long long ans = INF;
  for (auto i : ma) ans = min(ans, solve(i));
  cout << ans << '\n';
  return 0;
}
