#include <bits/stdc++.h>
using namespace std;
vector<int> generatePrimes() {
  const int nmax = int(2e9);
  int k = (int)sqrt(nmax);
  vector<int> primes;
  vector<bool> p(k + 1);
  for (int i = 2; i <= k; i++) {
    if (!p[i]) {
      primes.push_back(i);
      for (int j = i + i; j <= k; j += i) {
        p[j] = 1;
      }
    }
  }
  return primes;
}
long long solve(int N, long long a, vector<long long>& c,
                vector<vector<long long>>& cost) {
  cost[0][0] = cost[2][0] = c[0];
  cost[1][0] = a;
  for (int i = 1; i < N; ++i) {
    cost[0][i] = cost[0][i - 1] + c[i];
    cost[1][i] = a + min(cost[0][i - 1], cost[1][i - 1]);
    cost[2][i] = min(cost[2][i - 1], cost[1][i - 1]) + c[i];
    for (int k = 0; k < 3; k++) cost[k][i] = min(cost[k][i], 1LL << 50);
  }
  return min(cost[0][N - 1], min(cost[1][N - 1], cost[2][N - 1]));
}
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  vector<int> primes = generatePrimes();
  vector<int> vv(n);
  unordered_set<int> s;
  for (int i = 0; i < n; i++) {
    cin >> vv[i];
  }
  for (int y : vector<int>{vv[0], vv[n - 1]}) {
    for (int k = -1; k < 2; k++) {
      int x = y + k;
      for (int j = 0; primes[j] * primes[j] <= x; j++) {
        if (x % primes[j] == 0) {
          while (x % primes[j] == 0) x /= primes[j];
          s.insert(primes[j]);
        }
      }
      if (x > 1) {
        s.insert(x);
      }
    }
  }
  long long ans = 1LL << 60;
  vector<long long> c(n);
  vector<vector<long long>> cost(3, vector<long long>(n));
  for (const int& p : s) {
    for (int i = 0; i < n; i++) {
      if (vv[i] % p == 0)
        c[i] = 0;
      else if ((vv[i] - 1) % p == 0 or (vv[i] + 1) % p == 0)
        c[i] = b;
      else
        c[i] = 1LL << 40;
    }
    ans = min(ans, solve(n, a, c, cost));
  }
  cout << ans;
}
