#include <bits/stdc++.h>
using namespace std;
inline long long MIN(long long a, long long b) { return (a > b) ? b : a; }
inline long long MAX(long long a, long long b) { return (a < b) ? b : a; }
long long tab[1000100];
int n;
long long a, b;
vector<int> primes;
char p[1001000 / 8];
void GeneratePrimes() {
  primes.push_back(2);
  int i;
  for (i = 1; ((i * i) << 1) + (i << 1) < 1001000; ++i) {
    if ((p[i >> 3] & (1 << (i & 7))) == 0) {
      primes.push_back((i << 1) + 1);
      for (int j = ((i * i) << 1) + (i << 1), k = (i << 1) + 1;
           (j << 1) + 1 < 1001000; j += k) {
        p[j >> 3] |= (1 << (j & 7));
      }
    }
  }
  for (; (i << 1) + 1 < 1001000; ++i) {
    if ((p[i >> 3] & (1 << (i & 7))) == 0) {
      primes.push_back((i << 1) + 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  GeneratePrimes();
  cin >> n >> a >> b;
  for (int i = 0; i < n; ++i) cin >> tab[i];
  vector<long long> prep;
  prep.push_back(tab[0]);
  prep.push_back(tab[0] - 1);
  prep.push_back(tab[0] + 1);
  prep.push_back(tab[n - 1]);
  prep.push_back(tab[n - 1] + 1);
  prep.push_back(tab[n - 1] - 1);
  long long maximum = 0;
  for (int i = 0; i < n; ++i) maximum = MAX(maximum, tab[i]);
  long long minimum = (1LL << 62);
  bool first = true;
  vector<long long> numbers;
  for (int i = 0; i < prep.size(); ++i) {
    for (int j = 0; j < primes.size(); ++j) {
      if (prep[i] % primes[j] == 0) {
        numbers.push_back(primes[j]);
        while (prep[i] % primes[j] == 0) prep[i] /= primes[j];
      }
    }
    if (prep[i] > 1) numbers.push_back(prep[i]);
  }
  primes.clear();
  for (int i = 0; i < numbers.size(); ++i) primes.push_back(numbers[i]);
  for (int j = 0; j < primes.size(); ++j) {
    long long tmp = 0;
    long long discount = 0;
    int left = n;
    int right = -1;
    for (int i = 0; i < n; ++i) {
      int p = tab[i] % primes[j];
      if (p == 1 || p == primes[j] - 1) {
        tmp += b;
      } else if (p != 0) {
        left = MIN(i, left);
        right = MAX(i, right);
      }
    }
    if (left != n && right != -1 && right - left != n - 1) {
      for (int i = left; i <= right; ++i) {
        int p = tab[i] % primes[j];
        if (p == 1 || p == primes[j] - 1) tmp -= b;
      }
      tmp += (right - left + 1) * a;
      long long auxl1 = 0;
      long long auxl2 = 0;
      long long auxr1 = 0;
      long long auxr2 = 0;
      long long aux = 0;
      int posl = left;
      for (int i = left - 1; i >= 0; --i) {
        aux += a;
        if (tab[i] % primes[j]) {
          aux -= b;
        }
        if (auxl1 > aux) {
          auxl2 = auxl1;
          auxl1 = aux;
          posl = left;
        } else if (auxl2 > aux) {
          auxl2 = aux;
        }
      }
      int posr = right;
      aux = 0;
      for (int i = right + 1; i < n; ++i) {
        aux += a;
        if (tab[i] % primes[j]) {
          aux -= b;
        }
        if (auxr1 > aux) {
          auxr2 = auxr1;
          auxr1 = aux;
          posr = i;
        } else if (auxr2 > aux) {
          auxr2 = aux;
        }
      }
      if (!(posl == 0 && posr == n - 1)) {
        long long m = MIN(auxr1 + auxl1, 0);
        tmp += m;
      } else {
        long long m = MIN(auxr1 + auxl2, auxr2 + auxl1);
        m = MIN(m, 0);
        tmp += m;
      }
      minimum = MIN(minimum, tmp);
    } else if (right == -1) {
      minimum = MIN(tmp, minimum);
      long long sum = 0;
      long long sumMax1 = 0;
      long long sumMax2 = 0;
      int cnt = 0;
      for (int i = 0; i < n; ++i) {
        sum += a;
        cnt++;
        int p = tab[i] % primes[j];
        if (p != 0) {
          sum -= b;
        }
        if (sum > 0) {
          sum = 0;
          cnt = 0;
        }
        if (sum < sumMax1) {
          sumMax2 = sumMax1;
          sumMax1 = sum;
        } else if (sum < sumMax2)
          sumMax2 = sum;
      }
      if (cnt == n) {
        minimum = MIN(tmp + sumMax2, minimum);
      } else {
        minimum = MIN(tmp + sumMax1, minimum);
      }
      cnt = 0;
      sum = 0;
      for (int i = n - 1; i >= 0; --i) {
        sum += a;
        cnt++;
        int p = tab[i] % primes[j];
        if (p != 0) {
          sum -= b;
        }
        if (sum > 0) {
          sum = 0;
          cnt = 0;
        }
        if (sum < sumMax1) {
          sumMax2 = sumMax1;
          sumMax1 = sum;
        } else if (sum < sumMax2)
          sumMax2 = sum;
      }
      if (cnt == n) {
        minimum = MIN(tmp + sumMax2, minimum);
      } else {
        minimum = MIN(tmp + sumMax1, minimum);
      }
    }
  }
  cout << minimum << endl;
  return 0;
}
