#include <bits/stdc++.h>
using namespace std;
const int M = 25;
int n, a, b, ans, x1[M], x2[M];
int main() {
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 1; i <= n; ++i) scanf("%d", &x1[i]), x2[n - i + 1] = x1[i];
  for (int i = 1; i <= n; ++i)
    if (x1[i] == 2)
      ans += (x2[i] == 2 ? min(a, b) : (x2[i] ? b : a));
    else if (x1[i] != x2[i] && x2[i] != 2)
      puts("-1"), exit(0);
  printf("%d\n", ans);
}
