public int[] add(final int[] A, final int i, final int y) {
        // B is used for sums
        final int n = A.length;
        final int[] B = new int[n];
        final int used = (int) Math.round(Math.log(n) / Math.log(2));
        final int interval = used - 1;
        int sum = 0;
        int k = 0;

        A[i] = A[i] + y;

        for (int j = 0; j < n; j++) {
            sum = sum + B[j];
            k++;
            if (k == interval) {
                if (j + interval < n) {
                    if (i <= j + interval) {
                        sum = sum + y;
                    }
                    B[j + interval] = sum;
                    k = 0;
                    continue;
                } else {
                    break;
                }
            }
        }

        return A;
    }