BinaryIndexTree first problem WA(GRAVELS)

hello everyone…Today i tried to learn some new stuff and found fewnick tree/BIT cool…I tried my first problem and got wrong answer in it i have been debugging for a while but cannot find error.i request you to find error so that i can improve… :slight_smile: link to problem ,solution link

You are not adding the previous value in add function.It should be like this=>
void add(int index,int value)
{
while(index<=n)
{
tree[index]+=value;
index+=(index&-index);
}
}

anybody??please