#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
inline int read() {
  register int x = 0, f = 0;
  register char c = getchar();
  while (c < '0' || c > '9') f |= c == '-', c = getchar();
  while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar();
  return f ? -x : x;
}
int n;
long long A, B;
int a[N];
namespace Work1 {
long long ans = 1e16;
int gcd(int a, int b) {
  if (!a || !b)
    return a + b;
  else
    return gcd(b, a % b);
}
void dfs(int x, long long res, int L, int R, int Gcd) {
  if (L <= x && x <= R) return dfs(R + 1, res, L, R, Gcd);
  if (res >= ans || Gcd == 1) return;
  if (x == n + 1) {
    ans = min(ans, res);
    return;
  }
  dfs(x + 1, res + B, L, R, gcd(Gcd, a[x] - 1));
  dfs(x + 1, res + B, L, R, gcd(Gcd, a[x] + 1));
  dfs(x + 1, res, L, R, gcd(Gcd, a[x]));
}
int main() {
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      if (A * (j - i + 1) >= ans) break;
      dfs(1, A * (j - i + 1), i, j, 0);
    }
  }
  cout << ans << '\n';
  return 0;
}
}  // namespace Work1
namespace Work2 {
int tot;
int prime[10000];
long long dp[N][3], cost[N];
void Init(int x) {
  for (int i = 2; i * i <= x; ++i) {
    if (x % i == 0) {
      prime[++tot] = i;
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) prime[++tot] = x;
}
long long solve(int x) {
  memset(dp, 0, sizeof dp);
  for (int i = 1; i <= n; ++i) {
    if (a[i] % x == 0)
      cost[i] = 0;
    else if ((a[i] + 1) % x == 0 || (a[i] - 1) % x == 0)
      cost[i] = B;
    else
      cost[i] = 1e16;
  }
  for (int i = 1; i <= n; ++i) {
    if (cost[i] == 1e16) {
      dp[i][0] = 1e16;
      dp[i][1] = min(dp[i - 1][1], dp[i - 1][0]) + A;
      dp[i][2] = 1e16;
    } else {
      dp[i][0] = dp[i - 1][0] + cost[i];
      dp[i][1] = min(dp[i - 1][1], dp[i - 1][0]) + A;
      dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]) + cost[i];
    }
  }
  return min(dp[n][0], min(dp[n][1], dp[n][2]));
}
int main() {
  Init(a[1]);
  Init(a[1] + 1);
  Init(a[1] - 1);
  Init(a[n]);
  Init(a[n] + 1);
  Init(a[n] - 1);
  sort(prime + 1, prime + 1 + tot);
  tot = unique(prime + 1, prime + 1 + tot) - prime - 1;
  long long ans = 1e16;
  for (int i = 1; i <= tot; ++i) ans = min(ans, solve(prime[i]));
  cout << ans << '\n';
  return 0;
}
}  // namespace Work2
int main() {
  n = read();
  A = read();
  B = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  if (A == 0 || B == 0)
    cout << 0 << '\n';
  else
    Work2::main();
  fclose(stdin);
  fclose(stdout);
  return 0;
}
