very simple to write....Binary indexed tree...alias FenwickTree.java.