#include <bits/stdc++.h>
using namespace std;
int a[100000];
int b[100000];
int posa[100000];
int posb[100000];
int n;
int main() {
  cin >> n;
  for (int i = 0; i < (int)(n); i++) scanf("%d", a + i);
  for (int i = 0; i < (int)(n); i++) scanf("%d", b + i);
  for (int i = 0; i < (int)(n); i++) {
    posa[--a[i]] = i;
    posb[--b[i]] = i;
  }
  multiset<int> distance;
  for (int i = 0; i < (int)(n); i++) distance.insert(posb[i] - posa[i]);
  for (int k = 0; k < (int)(n); k++) {
    multiset<int>::iterator it = distance.lower_bound(k);
    int p = *it - k;
    int q = p;
    if (it != distance.begin()) q = k - (*--it);
    cout << min(p, q) << endl;
    distance.erase(distance.find(k - posa[b[k]]));
    distance.insert(n + k - posa[b[k]]);
  }
  return 0;
}
