#include <bits/stdc++.h>
using namespace std;
const int INF = (~(1 << 31)) - 5;
int n, aa, b;
long long ans = 9999999999999999LL;
long long f[1000005][3];
int s[1000005];
vector<int> prime;
void F(int x) {
  int sqr = sqrt(x + 0.5);
  for (int i = 2; i <= sqr; i++) {
    if (x % i == 0) {
      prime.push_back(i);
      while (x % i == 0) {
        x /= i;
      }
    }
  }
  if (x > 1) prime.push_back(x);
}
long long _min(long long a, long long b, long long c) {
  if (b > a) b = a;
  if (c > b) c = b;
  return c;
}
void dp(int a) {
  memset(f, 0x3f, sizeof(f));
  f[0][0] = 0;
  for (register int i = 1; i <= n; i++) {
    int c = -1;
    if (s[i] % a == 0) c = 0;
    if ((s[i] - 1) % a == 0 || (s[i] + 1) % a == 0) c = b;
    if (c != -1) {
      f[i][0] = min(f[i][0], f[i - 1][0] + (long long)c);
      f[i][2] = min(f[i][2], min(f[i - 1][2], f[i - 1][1]) + (long long)c);
    }
    f[i][1] = min(f[i - 1][0], f[i - 1][1]) + (long long)aa;
  }
  ans = min(ans, _min(f[n][0], f[n][1], f[n][2]));
}
void Work(int a, int cost, int x, int y) { F(a); }
int main() {
  scanf("%d%d%d", &n, &aa, &b);
  for (int i = 1; i <= n; i++) scanf("%d", &s[i]);
  F(s[1]);
  F(s[1] - 1);
  F(s[1] + 1);
  F(s[n]);
  F(s[n] - 1);
  F(s[n] + 1);
  sort(prime.begin(), prime.end());
  unique(prime.begin(), prime.end());
  for (int i = 0; i < prime.size(); i++) {
    dp(prime[i]);
  }
  cout << ans << endl;
  return 0;
}
