#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;
}
