BIT array size is n+1, getSum is called with k+1 (where k may be n, because it is 1-based), and getSum itself does index + 1 before performing an array access.
EDIT: Store all queries, calculate maximum list size that will be necessary (without answering queries). As far as I can see this should be sufficient to determine storage for BIT and get rid of map.
Actually, fixing this approach is not that simple.