BIT IMplementationBIT IMplementation

i have implemented the code given in video but its not working.

#include <bits/stdc++.h>
#define endl “\n”
#define ll long long int
#define vi vector
#define vll vector
#define vvi vector
#define pii pair<int, int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all© c.begin(), c.end()
#define mp(x, y) make_pair(x, y)
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define f first
#define s second

//PROBLEM IS RANGE SUM QUERY
//BINARY INDEX TREE
int a[10000];
int BIT[10000] = {0};

//Range Sum Query -log(n)
void update(int i, int inc, int N)
{
while (i <= N)
{
BIT[i] += inc;
i += (i & (-i));
}
}

//Sum till ith index // log(n)
int query(int i)
{
int ans = 0;
while (i >= 0)
{
ans += BIT[i];
i -= (i & (-i) );
}
return ans;
}

using namespace std;
int main()
{
std::ios::sync_with_stdio(false);
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
update(i, a[i], n);
}
int q;
cin >> q;
while (q–)
{
int l, r;
cin >> l >> r;
cout << query® - query(l - 1) << endl;
}

return 0;

}