#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000100;
int n, arr[MAX];
long long mem[MAX][3], a, b, ans = (1LL << 60);
vector<int> factorize(int num) {
  vector<int> ret;
  for (int i = 2; i <= num / i; i += 1 + (i & 1))
    while (num % i == 0) ret.push_back(i), num /= i;
  if (num > 1) ret.push_back(num);
  return ret;
}
long long dp(int idx, int flag, int p) {
  if (idx == n) return 0;
  long long &ret = mem[idx][flag];
  if (ret != -1) return ret;
  if (arr[idx] % p == 0)
    ret = dp(idx + 1, 2 * (flag != 0), p);
  else if ((arr[idx] - 1) % p == 0 || (arr[idx] + 1) % p == 0)
    ret = b + dp(idx + 1, 2 * (flag != 0), p);
  else
    ret = (1LL << 60);
  if (flag < 2) ret = min(ret, a + dp(idx + 1, 1, p));
  return ret;
}
int main() {
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) cin >> arr[i];
  int f[6] = {arr[0],     arr[0] - 1,     arr[0] + 1,
              arr[n - 1], arr[n - 1] - 1, arr[n - 1] + 1};
  set<int> s;
  for (int i = 0; i < 6; i++) {
    vector<int> temp = factorize(f[i]);
    s.insert(temp.begin(), temp.end());
  }
  for (int p : s) {
    memset(mem, -1, (n + 1) * sizeof mem[0]);
    ans = min(ans, dp(0, 0, p));
  }
  cout << ans << endl;
  return 0;
}
