#include <bits/stdc++.h>   using namespace std;   int N, a[100010], b[100010], posA[100010];   multiset<int> S;   int get(int x) {     multiset<int>::iterator it = S.lower_bound(x), jt = it;     return min(abs(*it - x), abs(*--jt - x));   }   int main() {     scanf( %d , &N);     for (int i = 1; i <= N; i++) scanf( %d , &a[i]), posA[a[i]] = i;     for (int i = 1; i <= N; i++) scanf( %d , &b[i]), S.insert(i - posA[b[i]]);     S.insert(-1e9);     for (int x = 1; x <= N; x++) {       printf( %d n , get(x - 1));       S.erase(S.find(x - posA[b[x]]));       S.insert(x - posA[b[x]] + N);     }   }   