def simplifyWord(word):
    """
    Perform cancellations in a word.

    Input word should be a list of integers;
        [1, 1, -2] means x_1^2 x_2^{-1}

    """
    not_stuck = True
    while not_stuck:
        not_stuck = False
        prev = None
        new_word = []
        for x in word:
            if prev == -x:
                prev = None
                not_stuck = True
            else:
                if prev is not None:
                    new_word.append(prev)
                prev = x
        if prev is not None:
            new_word.append(prev)
        word = new_word
    return word
