def sz_to_ind(sz, charge, nsingle):
    """
    Converts :math:`S_{z}` to a list index.

    Parameters
    ----------
    sz : int
        Value :math:`S_{z}` of a spin projection in the z direction.
    charge : int
        Value of the charge.
    nsingle : int
        Number of single particle states.

    Returns
    -------
    int
        Value of the list index corresponding to sz.
    """
    szmax = min(charge, nsingle-charge)
    return int((szmax+sz)/2)