#include <bits/stdc++.h>
using namespace std;
const long long MX = 1e6 + 9, INF = 1e16;
long long arr[MX], dp[MX][3];
set<long long> s;
void FUN(long long x) {
  if (x == 2) return;
  for (long long i = 2; i * i <= x; i++)
    while (x > 1 && x % i == 0) x /= i, s.insert(i);
  if (x > 1) s.insert(x);
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, a, b;
  cin >> n >> a >> b;
  for (long long i = 0; i < n; i++) cin >> arr[i];
  FUN(arr[0] + 1);
  FUN(arr[0]);
  FUN(arr[0] - 1);
  FUN(arr[n - 1] + 1);
  FUN(arr[n - 1]);
  FUN(arr[n - 1] - 1);
  long long minn = 1e18;
  for (long long x : s) {
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for (long long i = 1; i <= n; i++) {
      if (arr[i - 1] % x == 0 || arr[i - 1] % x == 1 ||
          arr[i - 1] % x == x - 1) {
        dp[i][0] = dp[i - 1][0] + b * (arr[i - 1] % x != 0);
        dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + a;
        dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]) + b * (arr[i - 1] % x != 0);
      } else {
        dp[i][0] = dp[i][2] = INF;
        dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + a;
      }
      dp[i][0] = min(INF, dp[i][0]), dp[i][1] = min(INF, dp[i][1]),
      dp[i][2] = min(INF, dp[i][2]);
    }
    minn = min(min(minn, dp[n][0]), min(dp[n][1], dp[n][2]));
  }
  cout << minn;
  return 0;
}
