Time limit: 2s. Memory limit: 512 MB.

Build a binary indexed tree.

4
1 3 2 4
10