#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
const long long inf = 1e18;
int c[N];
long long dp[3][N];
vector<int> v;
int n;
long long a, b;
long long cal(int x) {
  for (int i = 0; i < 3; i++) {
    dp[i][0] = inf;
  }
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    if (c[i] % x == 0) {
      dp[0][i] = dp[0][i - 1];
      dp[1][i] = min(dp[0][i - 1], dp[1][i - 1]) + a;
      dp[2][i] = min(dp[1][i - 1], dp[2][i - 1]);
    } else if ((c[i] - 1) % x == 0 || (c[i] + 1) % x == 0) {
      dp[0][i] = dp[0][i - 1] + b;
      dp[1][i] = min(dp[0][i - 1], dp[1][i - 1]) + a;
      dp[2][i] = min(dp[1][i - 1], dp[2][i - 1]) + b;
    } else {
      dp[0][i] = inf;
      dp[1][i] = min(dp[0][i - 1], dp[1][i - 1]) + a;
      dp[2][i] = inf;
    }
  }
  long long ans = inf;
  for (int i = 0; i < 3; i++) {
    ans = min(ans, dp[i][n]);
  }
  return ans;
}
long long f(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      v.push_back(i);
      while (x % i == 0) {
        x /= i;
      }
    }
  }
  long long ans = inf;
  if (x != 1) v.push_back(x);
  for (int i = 0; i < v.size(); i++) {
    ans = min(ans, cal(v[i]));
  }
  return ans;
}
int main() {
  scanf("%d%I64d%I64d", &n, &a, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
  }
  long long ans = inf;
  for (int i = c[1] - 1; i <= c[1] + 1; i++) {
    ans = min(ans, f(i));
  }
  for (int i = c[n] - 1; i <= c[n] + 1; i++) ans = min(ans, f(i));
  printf("%I64d\n", ans);
}
