#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int a[N];
vector<int> pp;
long long n, A, B;
void prime(int first) {
  int i;
  for (i = 2; i <= sqrt(first); ++i)
    if (first % i == 0) {
      while (first % i == 0) first /= i;
      pp.push_back(i);
    }
  if (first > 1) pp.push_back(first);
}
long long get(int r) {
  int i;
  long long T = n * A, K = 0;
  priority_queue<pair<long long, int> > q;
  for (i = n; i >= 1; --i) {
    T -= A;
    if (a[i] % r != 0) {
      if (((a[i] + 1) % r == 0 || (a[i] - 1) % r == 0))
        K += B;
      else
        break;
    }
    q.push(make_pair(-(T + K), i));
  }
  long long ret = 8e18;
  if (!q.empty()) ret = -q.top().first;
  K = 0, T = 0;
  for (i = 1; i < n; ++i) {
    if (a[i] % r != 0) {
      if (((a[i] + 1) % r == 0 || (a[i] - 1) % r == 0))
        K += B;
      else
        break;
    }
    T += A;
    while (!q.empty()) {
      if (q.top().second > i) break;
      q.pop();
    }
    ret = min(ret, K + A * (n - i));
    if (!q.empty()) ret = min(ret, K - q.top().first - T);
  }
  return ret;
}
int main() {
  int i, j, k;
  cin >> n >> A >> B;
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (i = -1; i <= 1; ++i) prime(a[1] + i), prime(a[n] + i);
  sort(pp.begin(), pp.end());
  vector<int>::iterator it = unique(pp.begin(), pp.end());
  pp.resize(distance(pp.begin(), it));
  long long ret = 8e18;
  for (i = 0; i < pp.size(); ++i) ret = min(ret, get(pp[i]));
  cout << ret << endl;
}
