def unsign(x: int) -> int:
    """
    Encode a signed integer as an unsigned integer, in such a way that values
    close to zero end up close to zero. Credit for this way of encoding integers
    goes to the FLAC format, which encodes deltas in a similar manner.

    For a 30k file, 75 MB corpus, these are the sizes after compressing with
    Brotli -9:

    * Raw u32le:                   623871 bytes
    * Delta, i3le:                 620851 bytes
    * Delta, u32le through unsign: 619479 bytes
    * Delta, u16le through unsign: 615054 bytes

    So we can save a few bytes by encoding the deltas like this.
    """
    if x >= 0:
        return x * 2
    else:
        return (x * -2) - 1