@ifrunruhin @grg124

//shahil_005

// Some basic pre-written functions might have been copied from www.geeksforgeeks.org or cp-algorithms.com//

#include <bits/stdc++.h>

using namespace std;

#define endl ‘\n’

#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int N = 1e5 + 5;

const long long MOD=(long long)(1e9+7);

const long long INIT=(long long)(1e6+1);

int32_t main()

{

int n,q,h;

cin >> n >> q >> h;

```
int a[q],b[h];
int t[100000] = {0};
for(int i=0;i<h;i++)
{
cin >> b[i];
t[b[i]]++;
}
for(int i=0;i<q;i++)
{
cin >> a[i];
}
for(int i=0;i<q;i++)
{
int l=1;
int j=a[i],k=a[i];
int ans=0;
while(l>0)
{
if(t[j] == 1 && j>0)
{
ans = abs(a[i] - j);
l=0;
}
else if(t[k] == 1 && k>0)
{
ans = abs(a[i] - k);
l=0;
}
j--;
k++;
}
cout << ans << endl;
}
return 0;
```

}