#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int mif = 0xcfcfcfcf;
const double PI = 3.14159265358979323846264338;
int num, ca, cb, sum, n, m, a, b;
deque<int> q;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> ca >> cb;
  q.clear();
  sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> num;
    q.push_back(num);
  }
  while (q.size() > 1) {
    a = q.front();
    b = q.back();
    q.pop_front();
    q.pop_back();
    if (a == 2 && b != 2)
      if (b == 0)
        sum += ca;
      else
        sum += cb;
    if (b == 2 && a != 2)
      if (a == 0)
        sum += ca;
      else
        sum += cb;
    if (a == 2 && b == 2) sum += 2 * min(ca, cb);
    if (a != 2 && b != 2 && a != b) {
      cout << "-1\n";
      return 0;
    }
  }
  if (q.empty() != 1) {
    a = q.front();
    if (a == 2) sum += min(ca, cb);
  }
  cout << sum << "\n";
}
