def get_chain_offsets(chainlist, chainlength, chainpadding):
    """Generates chain offsets

    :param chainlist: Sorted list of chain letters
    :param chainlength: chain length dictionary
    :param chainpadding: chain padding dictionary
    :return: dictionary of chain offsets
    """
    chainoffset = {}
    for a in range(len(chainlist)):
        if a > 0:
            chainoffset[chainlist[a]] = sum([0] + [chainlength[chainlist[b]] +
                                                   chainpadding[chainlist[b]]
                                                   for b in range(a)])
        else:
            chainoffset[chainlist[a]] = 0
    return chainoffset