#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = ((unsigned long long)(-1) >> 1);
inline void read2ints(long long& a, long long& b) { cin >> a >> b; }
inline void read3ints(long long& a, long long& b, long long& c) {
  cin >> a >> b >> c;
}
inline void read4ints(long long& a, long long& b, long long& c, long long& d) {
  cin >> a >> b >> c >> d;
}
inline void read5ints(long long& a, long long& b, long long& c, long long& d,
                      long long& e) {
  cin >> a >> b >> c >> d >> e;
}
template <typename T>
void read_vector(vector<T>& arg, long long size = 200000) {
  arg.resize(size);
  for (long long i = 0; i < size; ++i) {
    cin >> arg[i];
  }
}
void write_int_list(long long args, ...) {
  va_list lst;
  va_start(lst, args);
  for (long long i = 0; i < args; ++i) {
    long long a = va_arg(lst, long long);
    cout << a << " ";
  }
  va_end(lst);
}
void get_primes(set<long long>& primes, long long number) {
  for (long long i = 2; i * i <= number; ++i) {
    if (!(number % i)) {
      primes.insert(i);
    }
    while (!(number % i)) {
      number /= i;
    }
  }
  if (number != 1) {
    primes.insert(number);
  }
}
void write_set(set<long long>& lst) {
  for (auto i : lst) {
    cout << i << " ";
  }
}
void write_vector(vector<long long>& lst) {
  for (auto i : lst) {
    cout << i << " ";
  }
}
inline bool nei_is_not_mult(long long a, long long p) {
  return (a + 1) % p && (a - 1) % p;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w,
      x, y, z;
  read3ints(n, a, b);
  vector<long long> cs, helper;
  read_vector(cs, n);
  set<long long> primes;
  for (i = -1; i <= 1; ++i) {
    get_primes(primes, cs[0] + i);
    get_primes(primes, cs[n - 1] + i);
  }
  long long best = INF;
  helper.resize(n + 1);
  for (auto p : primes) {
    long long price = (n - 1) * a;
    long long bestprice = n * a;
    helper[0] = bestprice;
    for (i = 0; i < n; ++i, price -= a) {
      if (cs[i] % p) {
        if (nei_is_not_mult(cs[i], p)) {
          for (j = i + 1; j <= n; j++) helper[j] = helper[j - 1];
          break;
        } else {
          price += b;
        }
      }
      if (price <= bestprice) {
        bestprice = price;
        helper[i + 1] = price;
      } else {
        helper[i + 1] = helper[i];
      }
    }
    price = -a;
    for (j = n - 1; j >= 0; --j, price -= a) {
      if (cs[j] % p) {
        if (nei_is_not_mult(cs[j], p)) {
          break;
        } else {
          price += b;
        }
      }
      if (price + helper[j] <= bestprice) {
        bestprice = price + helper[j];
      }
    }
    best = min(best, bestprice);
  }
  cout << best;
  return 0;
}
