#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
int x[N], n, a, b;
long long f[N], pre[N];
long long get(int y) {
  int p = 0;
  for (int i = 1; i <= n; i++) {
    if (x[i] % y == 0)
      f[i] = f[i - 1];
    else if (x[i] % y == 1 || x[i] % y == y - 1)
      f[i] = f[i - 1] + b;
    else
      break;
    p = i;
  }
  for (int i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] + a;
    if (i <= p) pre[i] = min(f[i], pre[i]);
  }
  long long ans = pre[n];
  for (int i = n; i >= 1; i--) {
    if (x[i] % y == 0)
      f[i] = f[i + 1];
    else if (x[i] % y == 1 || x[i] % y == y - 1)
      f[i] = f[i + 1] + b;
    else
      break;
    ans = min(ans, pre[i - 1] + f[i]);
  }
  return ans;
}
int main() {
  scanf("%d %d %d", &n, &a, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%d", x + i);
  }
  int f[] = {x[1], x[n]};
  long long ans = 1ll * (n - 1) * a;
  for (int d = -1; d < 2; d++) {
    for (int k = 0; k < 2; k++) {
      int y = f[k] + d;
      for (int i = 2; i * i <= y; i++) {
        if (y % i) continue;
        ans = min(ans, get(i));
        while (y % i == 0) y /= i;
      }
      if (y != 1) ans = min(ans, get(y));
    }
  }
  cout << ans << endl;
  return 0;
}
