#include <bits/stdc++.h>
using namespace std;
int n, a, b, st, ed, ara[1000010], na[1000010], len, t[10], pr;
set<int> s;
set<int>::iterator it;
unsigned long long dp[1000010][5][2];
int main() {
  scanf("%d %d %d", &n, &a, &b);
  for (int i = 1; i <= n; i++) scanf("%d", &ara[i]);
  for (st = 1; st <= n && !ara[st]; st++)
    ;
  for (ed = n; ed >= 1 && !ara[ed]; ed--)
    ;
  for (int i = st; i <= ed; i++) na[++len] = ara[i];
  t[1] = na[1], t[2] = na[1] - 1, t[3] = na[1] + 1, t[4] = na[len],
  t[5] = na[len] - 1, t[6] = na[len] + 1;
  for (int i = 1; i <= 6; i++) {
    if (t[i] > 1) {
      int sq = sqrt(t[i]);
      for (int j = 2; j <= sq && t[i] > 1; j++) {
        if (t[i] % j == 0) s.insert(j);
        while (t[i] % j == 0) t[i] /= j;
      }
      if (t[i] != 1) s.insert(t[i]);
    }
  }
  unsigned long long ans = LLONG_MAX;
  for (it = s.begin(); it != s.end(); it++) {
    pr = *it;
    for (int pos = len + 1; pos >= 1; pos--) {
      for (int st = 2; st >= 0; st--) {
        for (int fe = 1; fe >= 0; fe--) {
          if (pos > len) {
            if (fe && st == 1)
              dp[pos][st][fe] = LLONG_MAX;
            else
              dp[pos][st][fe] = 0;
            continue;
          }
          unsigned long long op = LLONG_MAX;
          if (na[pos] % pr == 0) {
            if (st == 0 || st == 2)
              op = dp[pos + 1][st][fe];
            else
              op =
                  min(a + dp[pos + 1][1][fe || (pos == 1)], dp[pos + 1][2][fe]);
          } else {
            if (((ara[pos] - 1) % pr == 0) || ((ara[pos] + 1) % pr == 0)) {
              if (st == 0 || st == 2)
                op = b + dp[pos + 1][st][fe];
              else
                op = b + dp[pos + 1][2][fe];
            }
            if (st != 2) op = min(op, a + dp[pos + 1][1][fe || (pos == 1)]);
          }
          dp[pos][st][fe] = op;
        }
      }
    }
    ans = min(ans, dp[1][0][0]);
  }
  if (ans == LLONG_MAX) ans = 0;
  cout << ans << endl;
}
