#define PROBLEM "https://judge.yosupo.jp/problem/static_range_sum"
#include"../template.h"
#include"Fenwick/Fenwick.h"voidsolve(){intn,q;cin>>n>>q;Fenwick<ll>BIT(n);for(inti=1;i<=n;i++){intx;cin>>x;BIT.update(i,x);}while(q--){intl,r;cin>>l>>r;cout<<BIT.get(l+1,r)<<'\n';}}
#line 1 "DataStructure/Static_range_sum.test.cpp"
#define PROBLEM "https://judge.yosupo.jp/problem/static_range_sum"
#line 2 "template.h"
#include<bits/stdc++.h>usingnamespacestd;#define ll long long
#define MOD (ll)(1e9+7)
#define all(x) (x).begin(),(x).end()
#define unique(x) x.erase(unique(all(x)), x.end())
#define INF32 ((1ull<<31)-1)
#define INF64 ((1ull<<63)-1)
#define inf (ll)1e18
#define vi vector<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
constintmod=998244353;voidsolve();intmain(){ios_base::sync_with_stdio(false);cin.tie(NULL);// cin.exceptions(cin.failbit);// int t; cin >> t;// while(t--)solve();cerr<<"\nTime run: "<<1000*clock()/CLOCKS_PER_SEC<<"ms"<<'\n';return0;}#line 2 "DataStructure/Fenwick/Fenwick.h"
template<typenameT>structFenwick{intn;vector<T>fen;Fenwick(){}Fenwick(int_n):n(_n),fen(_n+1){}voidupdate(intpos,Tval){for(;pos<=n;pos+=pos&-pos){fen[pos]+=val;}}Tget(intpos){Tans=0;for(;pos>0;pos-=pos&-pos){ans+=fen[pos];}returnans;}Tget(intl,intr){returnget(r)-get(l-1);}voidupdate_range(intl,intr,Tval){update(l,val);update(r+1,-val);}voidreset(){fill(all(fen),T(0));}};#line 5 "DataStructure/Static_range_sum.test.cpp"
voidsolve(){intn,q;cin>>n>>q;Fenwick<ll>BIT(n);for(inti=1;i<=n;i++){intx;cin>>x;BIT.update(i,x);}while(q--){intl,r;cin>>l>>r;cout<<BIT.get(l+1,r)<<'\n';}}