Fenwick Tree added
made some changes in mincost