public  int queryTree(int index, int a, int b, int i, int j) {

        if (a > b || a > j || b < i)
            return Integer.MAX_VALUE;

        if (lazy[index] != 0) {
            tree[index] += lazy[index];

            if (a != b) {
                lazy[index * 2 + 1] += lazy[index];
                lazy[index * 2 + 2] += lazy[index];
            }

            lazy[index] = 0;
        }

        if (a >= i && b <= j)
            return tree[index];

        int q1 = queryTree(index * 2 + 1, a, (a + b) / 2, i, j);
        int q2 = queryTree(index * 2 + 2, 1 + (a + b) / 2, b, i, j);

        return q1 < q2 ? q1 : q2;
    }