#include <bits/stdc++.h>
using namespace std;
long long p[500], t;
long long x[1000100];
long long mem[1000100][3][2];
long long n, a, b;
map<long long, long long> mp;
void check(long long x) {
  long long i = 2;
  while (i * i <= x) {
    if (x % i == 0 && mp[i] == 0) p[t++] = i, mp[i] = 1;
    ;
    while (x % i == 0) x /= i;
    i++;
  }
  if (x > 1 && mp[x] == 0) p[t++] = x, mp[x] = 1;
  return;
}
long long P;
long long dp(long long cur, long long con, bool ch) {
  if (cur > n) {
    if (ch && con == 1) return (long long)1e17;
    return 0;
  }
  long long &ret = mem[cur][con][ch];
  if (ret != -1) return ret;
  ret = (long long)1e17;
  long long cur_con = con ? 2 : 0;
  bool chh = cur == 1 ? true : false;
  if (x[cur] % P == 0)
    ret = min(ret, dp(cur + 1, cur_con, ch));
  else if ((x[cur] + 1) % P == 0 || (x[cur] - 1) % P == 0)
    ret = min(ret, b + dp(cur + 1, cur_con, ch));
  if (con != 2 && n != 1) ret = min(ret, a + dp(cur + 1, 1, chh));
  return ret;
}
int main() {
  scanf("%lld %lld %lld", &n, &a, &b);
  for (long long i = 1; i <= n; i++) scanf("%lld", x + i);
  t = 0;
  check(x[1] + 1), check(x[1]), check(x[1] - 1);
  check(x[n] + 1), check(x[n]), check(x[n] - 1);
  long long ans = (long long)1e17;
  for (long long i = 0; i < t; i++) {
    P = p[i];
    memset(mem, -1, sizeof(mem));
    ans = min(ans, dp(1, 0, 0));
  }
  printf("%lld\n", ans);
  return 0;
}
