#include <bits/stdc++.h>
using namespace std;
const double PI = acos(0) * 2;
const double EPS = 1e-8;
const long long MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcounll(s);
}
int N, a, b, t[1000100], A, B, m[1000100];
set<int> Q;
void add(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      Q.insert(i);
    }
    while (x % i == 0) x /= i;
  }
  if (x > 1) Q.insert(x);
}
long long solve(int tar) {
  long long ret = 0;
  int L = N + 1, R = 0;
  for (int i = 1; i <= N; i++) {
    int tmp = (t[i] + 1) % tar;
    if (tmp == 0 || tmp == 2)
      m[i] = 1;
    else if (tmp != 1) {
      L = min(L, i);
      R = max(R, i);
    } else
      m[i] = 0;
  }
  for (int i = 1; i <= N; i++) {
    if (i >= L && i <= R) {
      ret += A;
    } else
      ret += B * m[i];
  }
  if (L != N + 1) {
    long long AR = 0, tmp = 0;
    for (int i = R + 1; i <= N; i++) {
      tmp += A - B * m[i];
      AR = min(AR, tmp);
    }
    tmp = 0;
    long long AL = 0;
    for (int i = L - 1; i >= 1; i--) {
      tmp += A - B * m[i];
      AL = min(AL, tmp);
    }
    return ret + AL + AR;
  } else {
    long long AWP = 0, M4 = 0, tmp = 0;
    for (int i = 1; i <= N; i++) {
      tmp += A - B * m[i];
      AWP = min(tmp - M4, AWP);
      M4 = max(M4, tmp);
    }
    return AWP + ret;
  }
}
int main() {
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++) cin >> t[i];
  Q.clear();
  for (int i = -1; i <= 1; i++) {
    add(t[1] + i);
    add(t[N] + i);
  }
  long long ans = 1e16;
  for (set<int>::iterator it = Q.begin(); it != Q.end(); it++) {
    ans = min(ans, solve(*it));
  }
  cout << ans << endl;
}
