#include <bits/stdc++.h>
using namespace std;
int N;
int a[100000], b[100000];
int p[100000], diff[100000];
set<pair<int, int> > pos;
set<pair<int, int>, greater<pair<int, int> > > neg;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    p[a[i]] = i;
  }
  for (int i = 0; i < N; i++) {
    cin >> b[i];
    diff[i] = i - p[b[i]];
    if (diff[i] >= 0)
      pos.insert(pair<int, int>(diff[i], b[i]));
    else
      neg.insert(pair<int, int>(diff[i], b[i]));
  }
  int a;
  set<pair<int, int> >::iterator it;
  set<pair<int, int>, greater<pair<int, int> > >::iterator nit;
  for (int i = 0; i < N; i++) {
    it = pos.begin();
    nit = neg.begin();
    if (it != pos.end()) a = abs(it->first - i);
    if (nit != neg.end()) a = min(a, abs(nit->first - i));
    cout << a << endl;
    pair<int, int> toRem = pair<int, int>(diff[i], b[i]);
    if (diff[i] >= i)
      pos.erase(toRem);
    else
      neg.erase(toRem);
    pos.insert(pair<int, int>(N - p[b[i]] + i, b[i]));
    diff[i] = N - p[b[i]] + i;
    it = pos.begin();
    while (it->first == i) {
      neg.insert(pair<int, int>(it->first, it->second));
      pos.erase(it);
      it = pos.begin();
    }
  }
  return 0;
}
