#include <bits/stdc++.h>
using namespace std;
long long n, a, b;
long long arr[1000002];
long long dp[1000002][3];
set<int> prime;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> a >> b;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 3; ++j) {
      int k = arr[i * (n - 1)] + j - 1;
      for (int j = 2; j < 1e9; ++j) {
        if (j * j > k) break;
        while (k % j == 0) {
          prime.insert(j);
          k /= j;
        }
      }
      if (k != 1 && k != 0) prime.insert(k);
    }
  }
  long long ans = 1e18;
  for (int p : prime) {
    for (int i = 0; i < n + 1; ++i)
      for (int j = 0; j < 3; ++j) dp[i][j] = 1e18;
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;
    for (int i = 0; i < n; ++i) {
      if (arr[i] % p == 0) {
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][0]);
        dp[i + 1][2] = min(dp[i + 1][2], dp[i][2]);
      } else {
        if ((arr[i] + 1) % p == 0 || (arr[i] - 1) % p == 0) {
          dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + b);
          dp[i + 1][2] = min(dp[i + 1][2], dp[i][2] + b);
        }
      }
      dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + a);
      dp[i + 1][1] = min(dp[i + 1][0], dp[i + 1][1]);
      dp[i + 1][2] = min(dp[i + 1][2], dp[i + 1][1]);
    }
    ans = min(ans, dp[n][2]);
  }
  cout << ans << endl;
}
