#include <bits/stdc++.h>
using namespace std;
long long n;
long long a, b;
set<int> primes;
void func(int num) {
  for (int i = 2; i * i <= num; i++) {
    if (num % i == 0) {
      primes.insert(i);
      while (num % i == 0) num /= i;
    }
  }
  if (num != 1) primes.insert(num);
}
long long calc(vector<int> &A, int p) {
  int si = -1, ei = -1;
  vector<long long> val(n + 3, 0);
  for (int i = 1; i <= n; i++) {
    if (A[i] % p == 0) {
      val[i] = 0;
    } else {
      if (((A[i] - 1) % p == 0) || (A[i] + 1) % p == 0) {
        val[i] = b;
      } else {
        val[i] = -1;
        si = i;
        break;
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    if (A[i] % p == 0) {
      val[i] = 0;
    } else {
      if (((A[i] - 1) % p == 0) || (A[i] + 1) % p == 0) {
        val[i] = b;
      } else {
        val[i] = -1;
        ei = i;
        break;
      }
    }
  }
  if (si == -1) {
    for (int i = 2; i <= n; i++) {
      val[i] += val[i - 1];
    }
    vector<long long> arr(n + 3);
    arr[1] = a;
    long long v = min(val[n], a + val[n] - val[1]);
    for (int i = 2; i <= n; i++) {
      arr[i] = min(arr[i - 1], val[i - 1]) + a;
      v = min(v, arr[i] + val[n] - val[i]);
    }
    return v;
  } else {
    for (int i = 2; i < si; i++) {
      val[i] += val[i - 1];
    }
    for (int i = n - 1; i > ei; i--) {
      val[i] += val[i + 1];
    }
    long long ans = a * (ei - si + 1);
    long long v = min((si - 1) * a, val[si - 1]);
    for (int i = si - 1; i >= 2; i--) {
      v = min(v, a * (si - i) + val[i - 1]);
    }
    ans += v;
    v = min(a * (n - ei), val[ei + 1]);
    for (int i = ei + 1; i <= n; i++) {
      v = min(v, a * (i - ei) + val[i + 1]);
    }
    ans += v;
    return ans;
  }
}
int main() {
  cin >> n >> a >> b;
  if (a == 0 || b == 0) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> A(n + 1);
  for (int i = 1; i <= n; i++) cin >> A[i];
  func(A[1]);
  func(A[1] + 1);
  if (A[1] != 2) func(A[1] - 1);
  func(A[n]);
  func(A[n] + 1);
  if (A[n] != 2) func(A[n] - 1);
  vector<int> ps;
  while (!primes.empty()) {
    ps.push_back(*primes.begin());
    primes.erase(primes.begin());
  }
  long long ans = (n - 1) * a;
  for (int i = 0; i < ps.size(); i++) {
    ans = min(ans, calc(A, ps[i]));
  }
  cout << ans << endl;
  return 0;
}
