#include <iostream>
typedef unsigned char byte;
byte calc_iv(byte buffer[], size_t len)
{
int iv = 0;
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, sizeof(buf)/sizeof(buf[0]));
std::cout<<(int)iv<<std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdHlwZWRlZiB1bnNpZ25lZCBjaGFyIGJ5dGU7CgpieXRlIGNhbGNfaXYoYnl0ZSBidWZmZXJbXSwgc2l6ZV90IGxlbikKewogICAgaW50IGl2ID0gMDsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBsZW47IGkrKykgewogICAgICAgIGJ5dGUgSSA9IGJ1ZmZlcltpXTsKICAgICAgICBpdiArPSBJOwogICAgICAgIGl2ICo9IEkgKyAxOwogICAgfQogICAgcmV0dXJuIGl2IC8gKGxlbik7Cn0KCmludCBtYWluKCl7CiAgICBieXRlIGJ1ZltdID0gezQxLCAzMiwgMTZ9OwogICAgYnl0ZSBpdiA9IGNhbGNfaXYoYnVmLCBzaXplb2YoYnVmKS9zaXplb2YoYnVmWzBdKSk7CiAgICBzdGQ6OmNvdXQ8PChpbnQpaXY8PHN0ZDo6ZW5kbDsKCiAgICByZXR1cm4gMDsKfQo=