def read_int(b, i, size=2):
    """Read an integer from bytearray.

    b -- bytearray
    i -- starting index
    size -- number of bytes to read
    """
    return int.from_bytes(b[i:i+size], byteorder='big', signed=True)