def state_to_int(p, statelist):
    """
    Converts array of fermion-configuration into integer
    Args:
        p - dictionary that contains the relevant system parameters
        statelist - fermion configuration
    Returns:
        out - integer corresponding to state
    """
    # construct unique integer for the fermion configuration defined
    # in statelist
    out = 0
    for ind, val in enumerate(statelist):
        out += val * 4**(p['N'] - ind - 1)
    out = int(out)
    return out