public static void main ( String [ ] $ ) {
  int n = gInt ( ) ;
  int [ ] a = in ( n ) , b = in ( n ) , c = in ( n ) ;
  long [ ] v1 = new long [ n ] , v2 = new long [ n ] ;
  {
    int v = 0 ;
    for ( int i = 0 ;
    i < n ;
    ++ i ) {
      for ( ;
      v < n && a [ v ] < b [ i ] ;
      ++ v ) {
      }
      v1 [ i ] = v ;
    }
  }
  Arrays . parallelPrefix ( v1 , Long :: sum ) ;
  {
    int v = 0 ;
    for ( int i = 0 ;
    i < n ;
    ++ i ) {
      for ( ;
      v < n && b [ v ] < c [ i ] ;
      ++ v ) {
      }
      v2 [ i ] = v == 0 ? 0 : v1 [ v - 1 ] ;
    }
  }
  System . out . println ( Arrays . stream ( v2 ) . sum ( ) ) ;
}

public static void main ( String [ ] $ ) { int n = gInt ( ) ; int [ ] a = in ( n ) , b = in ( n ) , c = in ( n ) ; long [ ] v1 = new long [ n ] , v2 = new long [ n ] ; { int v = 0 ; for ( int i = 0 ; i < n ; ++ i ) { for ( ; v < n && a [ v ] < b [ i ] ; ++ v ) { } v1 [ i ] = v ; } } Arrays . parallelPrefix ( v1 , Long :: sum ) ; { int v = 0 ; for ( int i = 0 ; i < n ; ++ i ) { for ( ; v < n && b [ v ] < c [ i ] ; ++ v ) { } v2 [ i ] = v == 0 ? 0 : v1 [ v - 1 ] ; } } System . out . println ( Arrays . stream ( v2 ) . sum ( ) ) ; }
(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: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier)))) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier)))) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier)))) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (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: (block (for_statement condition: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))) update: (update_expression (identifier)) body: (block)) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (method_reference (identifier) (identifier))))) (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (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: (block (for_statement condition: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))) update: (update_expression (identifier)) body: (block)) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (ternary_expression condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) consequence: (decimal_integer_literal) alternative: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list)))))))