#include using namespace std; #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #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; ll lg=18; 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]); } }; inline ll readll() { ll x = 0; char ch = getchar_unlocked(); while (ch < '0' || ch > '9') ch = getchar_unlocked(); while (ch >= '0' && ch <= '9'){ x = (x << 3) + (x << 1) + ch - '0'; ch = getchar_unlocked(); } return x; } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll L=readll(),n=readll(),q=readll(); assert(1<=L); assert(L<=cons); assert(1<=n); assert(n<=200000); assert(1<=q); assert(1<=200000); vi difpoint(n+3);rep(i,n)difpoint[i+1]=readll();difpoint[n+1]=inf/2;difpoint[n+2]=inf; rep(i,n)assert(1<=difpoint[i+1]&&difpoint[i+1]<=cons); rep(i,n-1)assert(difpoint[i+1]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; } ll d=max(v[ok]-cur-x,x-L-v[ok]+cur); ans=difpoint[ok]-d; ll r=idx; for(int c=lg-1;c>=0;c--){ 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)); chmin(ans,difpoint[r]-d); ans-=t; out(ans); } }