import math


def gcd(*args):
    """
    Generalize math.gcd to take more than two inputs.
    """
    items = list(args)
    while len(items) > 1:
        items.append(math.gcd(items.pop(), items.pop()))
    return items[0]