#include <iostream>
typedef unsigned char byte;
byte calc_iv(byte buffer[])
{
int iv = 0;
size_t len = sizeof(buffer); // get buffer size
for(int i = 0; i < len; i++) {
byte I = buffer[i];
iv += I;
iv *= I + 1;
}
return iv / (len);
}
int main(){
byte buf[] = {41, 32, 16};
byte iv = calc_iv(buf);
std::cout<<(int)iv<<std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdHlwZWRlZiB1bnNpZ25lZCBjaGFyIGJ5dGU7CgpieXRlIGNhbGNfaXYoYnl0ZSBidWZmZXJbXSkKewogICAgaW50IGl2ID0gMDsKICAgIHNpemVfdCBsZW4gPSBzaXplb2YoYnVmZmVyKTsgLy8gZ2V0IGJ1ZmZlciBzaXplCiAgICBmb3IoaW50IGkgPSAwOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICBieXRlIEkgPSBidWZmZXJbaV07CiAgICAgICAgaXYgKz0gSTsKICAgICAgICBpdiAqPSBJICsgMTsKICAgIH0KICAgIHJldHVybiBpdiAvIChsZW4pOwp9CgppbnQgbWFpbigpewogICAgYnl0ZSBidWZbXSA9IHs0MSwgMzIsIDE2fTsKICAgIGJ5dGUgaXYgPSBjYWxjX2l2KGJ1Zik7CiAgICAKICAgIHN0ZDo6Y291dDw8KGludClpdjw8c3RkOjplbmRsOwogICAgcmV0dXJuIDA7Cn0K