#include<bits/stdc++.h>
#define str to_string
using namespace std;
using ll=long long;
const int MAX=1e5+1;
int n,m,a[MAX],b[MAX];
int Reason(int tar){
int l=1,r=n;
while(l<=r){
int mid=(l+r)>>1;
if(a[mid]<tar)l=mid+1;
else r=mid-1;
}
return min(abs(tar-a[l-1]),abs(tar-a[r]));
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=m;i++)cin>>b[i];
sort(a+1,a+n+1);
int ans=0;
for(int i=1;i<=m;i++){
ans+=Reason(b[i]);
cout<<ans<<'\n';
}
cout<<ans<<'\n';
return 0;
}