#include <bits/stdc++.h>
using namespace std;
int n, x[1000002];
int a, b;
long long DP[1000002][3];
set<int> s;
void init() {
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
}
long long dp(int v) {
  DP[0][0] = 0;
  DP[0][1] = DP[0][2] = 1e18;
  for (int i = 0; i < n; ++i) {
    if (x[i] % v == 0) {
      DP[i + 1][0] = DP[i][0];
      DP[i + 1][1] = min(DP[i][0], DP[i][1]) + a;
      DP[i + 1][2] = min(DP[i][1], DP[i][2]);
    } else if ((x[i] + 1) % v == 0 || (x[i] - 1) % v == 0) {
      DP[i + 1][0] = DP[i][0] + b;
      DP[i + 1][1] = min(DP[i][0], DP[i][1]) + a;
      DP[i + 1][2] = min(DP[i][1], DP[i][2]) + b;
    } else {
      DP[i + 1][0] = DP[i + 1][2] = 1e18;
      DP[i + 1][1] = min(DP[i][0], DP[i][1]) + a;
    }
  }
  return min({DP[n][0], DP[n][1], DP[n][2]});
}
void solve() {
  int prime[6] = {x[0] - 1,     x[0],     x[0] + 1,
                  x[n - 1] - 1, x[n - 1], x[n - 1] + 1};
  for (int z = 0; z < 6; z++) {
    for (int i = 2; i * i <= prime[z]; ++i) {
      if (prime[z] % i == 0) {
        s.insert(i);
        while (prime[z] % i == 0) prime[z] /= i;
      }
    }
    if (prime[z] > 1) s.insert(prime[z]);
  }
  long long ans = 1e18;
  for (int i : s) {
    ans = min(ans, dp(i));
  }
  printf("%I64d\n", ans);
}
int main() {
  init();
  solve();
}
