#include using namespace std; #define rep(i, n) for(long long i=0;i<(long long)(n);i++) #define REP(i,k,n) for(long long i=k;i<(long long)(n);i++) typedef long long ll; #define all(a) a.begin(),a.end() #define lb(v,k) (lower_bound(all(v),(k))-v.begin()) ll cons=1000000000000000; ll inf=1001001001001001001; using vi=vector; using vvi=vector; typedef pair P; template bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;} template bool chmax(T&a,T b){if(a void out(T a){cout< void outp(T a){cout<<'('<=0){ Rmi[c+1][i]=min(Rmi[c][i],Rmi[c][ni]); Rma[c+1][i]=max(Rma[c][i],Rma[c][ni]); } } } ll mi(ll l,ll r){ if(l>=r)return inf; return min(Lmi[rng[r-l]][l],Rmi[rng[r-l]][r-1]); } ll ma(ll l,ll r){ if(l>=r)return -inf; return max(Lma[rng[r-l]][l],Rma[rng[r-l]][r-1]); } }; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll L,n,q;cin>>L>>n>>q; vi difpoint(n+3);rep(i,n)cin>>difpoint[i+1];difpoint[n+1]=inf/2;difpoint[n+2]=inf; n+=3; vvi tablema(20,vi(n)),tablemi(20,vi(n)); rep(i,n)tablema[0][i]=tablemi[0][i]=0; vi v(n); rep(i,n-1){ if(i%2)v[i+1]=v[i]-difpoint[i+1]+difpoint[i]; else v[i+1]=v[i]+difpoint[i+1]-difpoint[i]; } sparsetable sp(v); return 0; rep(c,19)rep(i,n){ ll ni=i+(1<>x>>t; x+=ans;t+=ans;x%=L;t%=cons; // outp(P(x,t)); ll idx=lb(difpoint,t); ll cur=val(t); ll ok=n,ng=idx-1; while(ok-ng>1){ ll md=(ok+ng)/2; if(sp.ma(idx,md+1)-cur>=x||sp.mi(idx,md+1)-cur<=x-L)ok=md; else ng=md; } // out(ok); ll d=max(v[ok]-cur-x,x-L-v[ok]+cur);assert(d>=0); ans=difpoint[ok]-d; // out(ans); ll r=idx; for(int c=19;c>=0;c--){ // out(r); ll nr=r+(1<=x||mi<=x-L)continue; r=nr; } d=max(v[r]-sp.mi(idx,r+1)-x,x-L-v[r]+sp.ma(idx,r+1));assert(d>=0); chmin(ans,difpoint[r]-d); ans-=t; out(ans); } }