def get_actual_endpoints(wgts, begin):
    """For the array of weights in *wgts* return the first and last
    calendar years that have some weight (contain a month with non-zero
    weight); assuming the array starts in year *begin*."""

    # Exact number of years.
    assert len(wgts) % 12 == 0
    y_min = 9999
    y_max = 0
    for i in range(0, len(wgts), 12):
        if sum(wgts[i:i + 12]) > 0:
            y = i // 12
            y_min = min(y_min, y)
            y_max = max(y_max, y)
    return begin + y_min, begin + y_max