#include <bits/stdc++.h>
using namespace std;

const int MX = 100005;
int n;
int a[MX], b[MX];
long long f[MX];
vector<int> A[MX], B[MX];

long long count(int u, int mid) {
    long long res = 0;
    for(int i = 0, j = 0; i < (int)A[u].size(); ++i) {
        while(j < B[u].size() && B[u][j] + mid <= A[u][i]) ++j;
        res += j;
    }
    for(int i = 0, j = 0; i < (int)B[u].size(); ++i) {
        while(j < A[u].size() && A[u][j] + mid <= B[u][i]) ++j;
        res += j;
    }
    return res;
}

bool check(int mid, int x) {
    for(int i = x; i <= n; i += x) f[i] = 0;
    for(int i = x; i <= n; i += x) f[i] = count(i, mid);
    for(int i = x * (n / x); i >= x; i -= x) {
        for(int j = i << 1; j <= n; j += i) {
            f[i] -= f[j];
        }
    }
    return f[x];
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    for(int i = 1; i <= n; ++i) cin >> b[i];
    for(int i = 1; i <= n; ++i) {
        for(int j = i; j <= n; j += i) {
            A[i].push_back(a[j]);
            B[i].push_back(b[j]);
        }
        sort(A[i].begin(), A[i].end());
        sort(B[i].begin(), B[i].end());
    }
    for(int i = 1; i <= n; ++i) {
        int res = 0;
        for(int lo = 0, hi = 1e9; lo <= hi;) {
            int mid = (lo + hi) >> 1;
            if(check(mid, i)) res = mid, lo = mid + 1;
            else hi = mid - 1;
        }
        cout << res << " ";
    }

    return 0;
}