#include <bits/stdc++.h>
using namespace std;
void NO() {
  cout << "No\n";
  exit(0);
}
int n, a, b;
long long vs[1000500], cost[1000500][3];
long long d[1000500][3];
long long ans;
const long long INF = 1e18;
long long findAns(int p) {
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= 2; ++j) d[i][j] = INF;
    cost[i][1] = a;
    cost[i][0] = INF;
    int ost = vs[i] % p;
    if (ost == 0)
      cost[i][0] = 0;
    else if (ost == 1 || ost == p - 1)
      cost[i][0] = b;
    cost[i][2] = cost[i][0];
  }
  d[0][0] = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j <= 2; ++j) {
      if (j < 2) d[i][j + 1] = min(d[i][j + 1], d[i][j]);
      d[i + 1][j] = min(d[i + 1][j], d[i][j] + cost[i][j]);
    }
  long long ans = min(d[n][0], min(d[n][1], d[n][2]));
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> a >> b;
  for (int i = 0; i < n; ++i) cin >> vs[i];
  vector<int> goodNums;
  for (int i = 0; i < n; i += n - 1) {
    for (int j = -1; j <= 1; ++j) {
      int x = vs[i] + j;
      if (x < 2) continue;
      for (int i = 2; i * i <= x; ++i)
        if (x % i == 0) {
          goodNums.push_back(i);
          while (x % i == 0) x /= i;
        }
      if (x > 1) goodNums.push_back(x);
    }
    if (n == 1) break;
  }
  long long ans = 1000000000;
  ans *= ans;
  for (int g : goodNums) ans = min(ans, findAns(g));
  cout << ans << "\n";
  return 0;
}
