#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1000100, INF = 1000000000000000100LL;
long long n, A, B, a[MAX], suma[MAX], zly[2];
set<long long> czynniki;
void wczytaj_dane() {
  cin >> n >> A >> B;
  for (long long i = (1); i <= (n); i++) cin >> a[i];
}
void dodaj_czynniki_liczby(long long b) {
  long long d = 2;
  while (d * d <= b) {
    if (b % d == 0) {
      while (b % d == 0) b /= d;
      czynniki.insert(d);
    }
    d++;
  }
  if (b > 1) czynniki.insert(b);
}
void dodaj_czynniki(long long b) {
  long long t[3] = {b - 1, b, b + 1};
  for (long long i = 0; i < (3); i++) dodaj_czynniki_liczby(t[i]);
}
void znajdz_czynniki() {
  dodaj_czynniki(a[1]);
  dodaj_czynniki(a[n]);
}
bool jest_zly(long long b, long long c) {
  long long d = b % c;
  return d != 0 && d != 1 && d != c - 1;
}
void przygotuj_sie(long long c) {
  zly[0] = n + 1;
  zly[1] = 0;
  suma[0] = 0;
  for (long long i = (1); i <= (n); i++) {
    suma[i] = suma[i - 1];
    if (jest_zly(a[i], c)) {
      zly[0] = min(zly[0], i);
      zly[1] = i;
    } else if (a[i] % c != 0)
      suma[i]++;
  }
}
long long f(long long i) { return i * A - suma[i] * B; }
long long maks_bez_poczatku() {
  long long maks = -INF;
  for (long long i = (2); i <= (n - 1); i++) maks = max(maks, f(i));
  return maks;
}
long long rozwiaz_niezly() {
  long long wynik = 0, maks = 0;
  for (long long j = (1); j <= (n - 1); j++) {
    wynik = min(wynik, f(j) - maks);
    maks = max(maks, f(j));
  }
  wynik = min(wynik, f(n) - maks_bez_poczatku());
  return wynik + suma[n] * B;
}
long long oblicz_poczatek(long long i) {
  return (zly[0] - i) * A + suma[i - 1] * B;
}
long long oblicz_koniec(long long i) {
  return (i - zly[1]) * A + (suma[n] - suma[i]) * B;
}
long long rozwiaz_zly() {
  long long pocz[2] = {INF, INF}, kon[2] = {INF, INF};
  pocz[0] = oblicz_poczatek(1);
  for (long long i = (2); i <= (zly[0]); i++)
    pocz[1] = min(pocz[1], oblicz_poczatek(i));
  kon[0] = oblicz_koniec(n);
  for (long long i = (zly[1]); i <= (n - 1); i++)
    kon[1] = min(kon[1], oblicz_koniec(i));
  return (zly[1] - zly[0] + 1) * A +
         min(min(pocz[0] + kon[1], pocz[1] + kon[0]), pocz[1] + kon[1]);
}
long long rozwiaz(long long c) {
  przygotuj_sie(c);
  return zly[1] == 0 ? rozwiaz_niezly() : rozwiaz_zly();
}
void zrob_test() {
  wczytaj_dane();
  znajdz_czynniki();
  long long wynik = INF;
  for (__typeof((czynniki).begin()) i = ((czynniki).begin());
       i != (czynniki).end(); i++)
    wynik = min(wynik, rozwiaz(*i));
  cout << wynik << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  zrob_test();
  return 0;
}

### Prompt

Please create a solution in Cpp to the following problem:

You are given array ai of length n. You may consecutively apply two operations to this array:

  * remove some subsegment (continuous subsequence) of length m < n and pay for it m·a coins; 
  * change some elements of the array by at most 1, and pay b coins for each change. 



Please note that each of operations may be applied at most once (and may be not applied at all) so you can remove only one segment and each number may be changed (increased or decreased) by at most 1. Also note, that you are not allowed to delete the whole array.

Your goal is to calculate the minimum number of coins that you need to spend in order to make the greatest common divisor of the elements of the resulting array be greater than 1.

Input

The first line of the input contains integers n, a and b (1 ≤ n ≤ 1 000 000, 0 ≤ a, b ≤ 109) — the length of the array, the cost of removing a single element in the first operation and the cost of changing an element, respectively.

The second line contains n integers ai (2 ≤ ai ≤ 109) — elements of the array.

Output

Print a single number — the minimum cost of changes needed to obtain an array, such that the greatest common divisor of all its elements is greater than 1.

Examples

Input

3 1 4
4 2 3


Output

1


Input

5 3 2
5 17 13 5 6


Output

8


Input

8 3 4
3 7 5 4 3 12 9 4


Output

13

Note

In the first sample the optimal way is to remove number 3 and pay 1 coin for it.

In the second sample you need to remove a segment [17, 13] and then decrease number 6. The cost of these changes is equal to 2·3 + 2 = 8 coins.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1000100, INF = 1000000000000000100LL;
long long n, A, B, a[MAX], suma[MAX], zly[2];
set<long long> czynniki;
void wczytaj_dane() {
  cin >> n >> A >> B;
  for (long long i = (1); i <= (n); i++) cin >> a[i];
}
void dodaj_czynniki_liczby(long long b) {
  long long d = 2;
  while (d * d <= b) {
    if (b % d == 0) {
      while (b % d == 0) b /= d;
      czynniki.insert(d);
    }
    d++;
  }
  if (b > 1) czynniki.insert(b);
}
void dodaj_czynniki(long long b) {
  long long t[3] = {b - 1, b, b + 1};
  for (long long i = 0; i < (3); i++) dodaj_czynniki_liczby(t[i]);
}
void znajdz_czynniki() {
  dodaj_czynniki(a[1]);
  dodaj_czynniki(a[n]);
}
bool jest_zly(long long b, long long c) {
  long long d = b % c;
  return d != 0 && d != 1 && d != c - 1;
}
void przygotuj_sie(long long c) {
  zly[0] = n + 1;
  zly[1] = 0;
  suma[0] = 0;
  for (long long i = (1); i <= (n); i++) {
    suma[i] = suma[i - 1];
    if (jest_zly(a[i], c)) {
      zly[0] = min(zly[0], i);
      zly[1] = i;
    } else if (a[i] % c != 0)
      suma[i]++;
  }
}
long long f(long long i) { return i * A - suma[i] * B; }
long long maks_bez_poczatku() {
  long long maks = -INF;
  for (long long i = (2); i <= (n - 1); i++) maks = max(maks, f(i));
  return maks;
}
long long rozwiaz_niezly() {
  long long wynik = 0, maks = 0;
  for (long long j = (1); j <= (n - 1); j++) {
    wynik = min(wynik, f(j) - maks);
    maks = max(maks, f(j));
  }
  wynik = min(wynik, f(n) - maks_bez_poczatku());
  return wynik + suma[n] * B;
}
long long oblicz_poczatek(long long i) {
  return (zly[0] - i) * A + suma[i - 1] * B;
}
long long oblicz_koniec(long long i) {
  return (i - zly[1]) * A + (suma[n] - suma[i]) * B;
}
long long rozwiaz_zly() {
  long long pocz[2] = {INF, INF}, kon[2] = {INF, INF};
  pocz[0] = oblicz_poczatek(1);
  for (long long i = (2); i <= (zly[0]); i++)
    pocz[1] = min(pocz[1], oblicz_poczatek(i));
  kon[0] = oblicz_koniec(n);
  for (long long i = (zly[1]); i <= (n - 1); i++)
    kon[1] = min(kon[1], oblicz_koniec(i));
  return (zly[1] - zly[0] + 1) * A +
         min(min(pocz[0] + kon[1], pocz[1] + kon[0]), pocz[1] + kon[1]);
}
long long rozwiaz(long long c) {
  przygotuj_sie(c);
  return zly[1] == 0 ? rozwiaz_niezly() : rozwiaz_zly();
}
void zrob_test() {
  wczytaj_dane();
  znajdz_czynniki();
  long long wynik = INF;
  for (__typeof((czynniki).begin()) i = ((czynniki).begin());
       i != (czynniki).end(); i++)
    wynik = min(wynik, rozwiaz(*i));
  cout << wynik << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  zrob_test();
  return 0;
}

```