def sum_formula_general_from_zero(d: int, n: int) -> int:
    """
    SUM k=0 to n-1 of (k*d)
    = n/2 ((n-1)d)
    https://www.mathsisfun.com/algebra/sequences-sums-arithmetic.html
    d = difference between terms
    n = amount of terms
    """
    assert n > 0, n
    return n * (n - 1) * d // 2