public static void main ( String [ ] args ) {
  Scanner s = new Scanner ( System . in ) ;
  int n = s . nextInt ( ) ;
  int a = s . nextInt ( ) ;
  int b = s . nextInt ( ) ;
  int d [ ] = new int [ n ] ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) d [ i ] = s . nextInt ( ) ;
  int min = Math . min ( a , b ) ;
  int j = 0 , k = n - 1 , ans = 0 ;
  while ( j <= k ) {
    boolean v = check ( d , j , k ) ;
    boolean v1 = check1 ( d , j , k ) ;
    if ( v == false ) {
      ans = - 1 ;
      break ;
    }
    else if ( v1 == true ) {
      if ( d [ j ] == d [ k ] && d [ k ] == 2 ) {
        if ( j == k ) ans = ans + min ;
        else if ( j < k ) ans = ans + min * 2 ;
      }
      else {
        if ( d [ j ] == 0 || d [ k ] == 0 ) ans = ans + a ;
        else if ( d [ j ] == 1 || d [ k ] == 1 ) ans = ans + b ;
      }
    }
    j ++ ;
    k -- ;
  }
  System . out . println ( ans ) ;
}

public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int a = s . nextInt ( ) ; int b = s . nextInt ( ) ; int d [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) d [ i ] = s . nextInt ( ) ; int min = Math . min ( a , b ) ; int j = 0 , k = n - 1 , ans = 0 ; while ( j <= k ) { boolean v = check ( d , j , k ) ; boolean v1 = check1 ( d , j , k ) ; if ( v == false ) { ans = - 1 ; break ; } else if ( v1 == true ) { if ( d [ j ] == d [ k ] && d [ k ] == 2 ) { if ( j == k ) ans = ans + min ; else if ( j < k ) ans = ans + min * 2 ; } else { if ( d [ j ] == 0 || d [ k ] == 0 ) ans = ans + a ; else if ( d [ j ] == 1 || d [ k ] == 1 ) ans = ans + b ; } } j ++ ; k -- ; } System . out . println ( ans ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal))) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier))))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (false))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))) (break_statement)) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (true))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) alternative: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))) consequence: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))) consequence: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))))))))))) (expression_statement (update_expression (identifier))) (expression_statement (update_expression (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))