#include <bits/stdc++.h>
using namespace std;
vector<int> ar;
long long int dp[1000005][4];
set<int> prime;
int n, a, b;
long long int ans = 1e18;
void factorise(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      prime.insert(i);
      while (n % i == 0) {
        n = n / i;
      }
    }
  }
  if (n > 1) prime.insert(n);
}
void solve(int gcd) {
  for (int i = 0; i <= n; i++) {
    dp[i][0] = dp[i][1] = dp[i][2] = 1E15;
  }
  dp[0][0] = dp[0][1] = dp[0][2] = 0;
  for (int i = 0; i < n; i++) {
    long long int cost = 1E15;
    int rem = ar[i] % gcd;
    if (rem == 1 || rem == gcd - 1) {
      cost = b;
    } else if (rem == 0)
      cost = 0;
    for (int j = 0; j < 3; j++) {
      if (j == 2) {
        dp[i + 1][2] = min(dp[i + 1][2], dp[i][2] + cost);
      } else if (j == 1) {
        dp[i + 1][2] = min(dp[i + 1][2], dp[i][1] + a);
        dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + a);
        dp[i][1] = min(dp[i][1], dp[i][2]);
      } else {
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + cost);
        dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + a);
        dp[i][1] = min(dp[i][1], dp[i][0]);
      }
    }
  }
  ans = min(ans, dp[n][0]);
  ans = min(ans, dp[n][1]);
  ans = min(ans, dp[n][2]);
}
int main() {
  cin >> n >> a >> b;
  ar.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  for (int i = -1; i <= 1; i++) {
    factorise(ar[0] + i);
    factorise(ar[n - 1] + i);
  }
  set<int>::iterator it;
  for (it = prime.begin(); it != prime.end(); it++) {
    solve(*it);
  }
  cout << ans;
}
