def remove_ngram(words, ngram):
    """
    Return list with all occurrences of n-gram removed.

    Examples:
        >>> remove_ngram(['foo', 'bar', 'ham', 'spam'], ('bar', 'ham'))
        ['foo', 'spam']
    """
    n = len(ngram)
    result = []
    n_iter = len(words) - n
    i = 0
    while i < n_iter:
        for j, word in enumerate(ngram):
            if word != words[i + j]:
                result.append(words[i + j])
                result.append(words[i])
                break
        else:
            i += n
    result.extend(words[i:])
    return result
