def get_array_value_dtype(lst):
    '''Return array value type, raise ConfigSerializeError for invalid arrays

    Libconfig arrays must only contain scalar values and all elements must be
    of the same libconfig data type. Raises ConfigSerializeError if these
    invariants are not met.

    Returns the value type of the array. If an array contains both int and
    long int data types, the return datatype will be ``'i64'``.
    '''

    array_value_type = None
    for value in lst:
        dtype = get_dump_type(value)
        if dtype not in {'b', 'i', 'i64', 'f', 's'}:
            raise ConfigSerializeError(
                "Invalid datatype in array (may only contain scalars):"
                "%r of type %s" % (value, type(value)))

        if array_value_type is None:
            array_value_type = dtype
            continue

        if array_value_type == dtype:
            continue

        if array_value_type == 'i' and dtype == 'i64':
            array_value_type = 'i64'
            continue

        if array_value_type == 'i64' and dtype == 'i':
            continue

        raise ConfigSerializeError(
            "Mixed types in array (all elements must have same type):"
            "%r of type %s" % (value, type(value)))

    return array_value_type
Return array value type, raise ConfigSerializeError for invalid arrays

    Libconfig arrays must only contain scalar values and all elements must be
    of the same libconfig data type. Raises ConfigSerializeError if these
    invariants are not met.

    Returns the value type of the array. If an array contains both int and
    long int data types, the return datatype will be ``'i64'``.