#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, MOD = 1e9 + 7, maxn = 1e6 + 7;
int s[maxn];
long long dp[maxn][4];
int n;
long long a, b, ans = 1e16;
void solve(int x) {
  memset(dp, INF, sizeof(dp));
  dp[0][1] = dp[0][2] = dp[0][3] = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] % x == 0) {
      dp[i][1] = dp[i - 1][1];
      dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]) + a;
      dp[i][3] = min(dp[i - 1][2], dp[i - 1][3]);
    } else if ((s[i] + 1) % x == 0 || (s[i] - 1) % x == 0) {
      dp[i][1] = dp[i - 1][1] + b;
      dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]) + a;
      dp[i][3] = min(dp[i - 1][3] + b, dp[i - 1][2] + min(a, b));
    } else {
      dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]) + a;
    }
  }
  ans = min(ans, min(dp[n][1], min(dp[n][2], dp[n][3])));
}
int main() {
  scanf("%d %I64d %I64d", &n, &a, &b);
  for (int i = 1; i <= n; i++) scanf("%d", &s[i]);
  int sum[3];
  sum[1] = s[1];
  sum[2] = s[n];
  for (int i = 1; i <= 2; i++) {
    for (int d = -1; d <= 1; d++) {
      long long temp = sum[i] + d;
      for (int j = 2; j * j <= temp; j++) {
        if (temp % j == 0) solve(j);
        while (temp % j == 0) temp /= j;
      }
      if (temp > 1) solve(temp);
    }
  }
  cout << ans << endl;
  return 0;
}
