#include <bits/stdc++.h>
using namespace std;
vector<long long> get(long long x) {
  vector<long long> v;
  long long y = x;
  for (long long i = 2; i * i <= x; i++) {
    if (y % i == 0) {
      v.push_back(i);
      while (y % i == 0) {
        y /= i;
      }
    }
  }
  if (y > 1) {
    v.push_back(y);
  }
  return v;
}
const long long N = 1e6 + 7, inf = 1e16;
long long arr[N], n, a, b, cost[N], suff[N], dp[N], ans = inf;
map<long long, long long> mp;
void solve(long long x) {
  if (mp[x]) {
    return;
  }
  mp[x] = 1;
  long long lst = 0;
  for (long long i = 1; i <= n; i++) {
    long long k = arr[i] % x;
    if (k == 0) {
      cost[i] = 0;
    } else if (k == 1 || k == x - 1) {
      cost[i] = b;
    } else {
      cost[i] = inf;
      lst = i;
    }
    suff[i] = cost[i];
    cost[i] += cost[i - 1];
    cost[i] = min(inf, cost[i]);
  }
  for (long long i = n; i >= 1; i--) {
    suff[i] += suff[i + 1];
  }
  ans = min(ans, cost[n]);
  dp[0] = 0;
  for (long long i = 1; i <= n; i++) {
    dp[i] = a + min(dp[i - 1], cost[i - 1]);
    if (lst <= i) {
      ans = min(ans, dp[i] + suff[i + 1]);
    }
  }
}
void f(long long x) {
  vector<long long> v = get(x);
  for (long long y : v) {
    solve(y);
  }
}
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> a >> b;
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  f(arr[1]);
  f(arr[n]);
  f(arr[1] + 1);
  f(arr[1] - 1);
  f(arr[n] + 1);
  f(arr[n] - 1);
  cout << ans << endl;
}
