#include <bits/stdc++.h>
using namespace std;
const long long inf = (1ll << 60);
int n, a, b;
int aa[1000011];
long long p1[1000011], p2[1000011];
int vec[1000011] = {}, num = 0;
bool vis[1000011] = {};
void getprime(int q) {
  for (int i = 2; i * i <= q; i++) {
    if (q % i != 0) continue;
    while (q % i == 0) q = q / i;
    if (vis[i] == true) continue;
    vis[i] = true;
    num++;
    vec[num] = i;
  }
  if (q != 1) {
    num++;
    vec[num] = q;
  }
}
long long solve(int k) {
  long long ans = inf;
  for (int i = 1; i <= n; i++) {
    p1[i] = p2[i] = inf;
  }
  p1[0] = p2[n + 1] = 0;
  for (int i = 1; i <= n; i++) {
    if (aa[i] % k == 0)
      p1[i] = p1[i - 1];
    else if ((aa[i] + 1) % k == 0 || (aa[i] - 1) % k == 0)
      p1[i] = p1[i - 1] + b;
  }
  for (int i = n; i >= 1; i--) {
    if (aa[i] % k == 0)
      p2[i] = p2[i + 1];
    else if ((aa[i] + 1) % k == 0 || (aa[i] - 1) % k == 0)
      p2[i] = p2[i + 1] + b;
  }
  long long mv = -a;
  for (int i = 1; i <= n; i++) {
    ans = min(ans, p2[i] + (long long)i * a + mv);
    mv = min(mv, p1[i] - (long long)(i + 1) * a);
  }
  for (int i = 1; i <= n; i++) {
    ans = min(ans, p1[i] + (long long)(n - i) * a);
  }
  return ans;
}
int main() {
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &aa[i]);
  }
  getprime(aa[1]);
  getprime(aa[1] + 1);
  getprime(aa[1] - 1);
  getprime(aa[n]);
  getprime(aa[n] + 1);
  getprime(aa[n] - 1);
  long long ans = inf;
  for (int i = 1; i <= num; i++) {
    ans = min(ans, solve(vec[i]));
  }
  cout << ans;
}
