#include <bits/stdc++.h>
using namespace std;
int n, minDist;
int a[100001], b[100001];
map<int, int> distInit;
set<pair<int, int> > pos, neg;
pair<int, int> tmpPair;
int main() {
  cin >> n;
  if (!n) return 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  for (int i = 0; i < n; ++i) {
    distInit[b[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    distInit[a[i]] -= i;
  }
  for (int i = 0; i < n; ++i) {
    tmpPair = make_pair(distInit[a[i]], a[i]);
    if (tmpPair.first > 0) {
      pos.insert(tmpPair);
    } else {
      neg.insert(tmpPair);
    }
  }
  set<pair<int, int> >::iterator it1 = pos.begin(), it2 = neg.end();
  minDist = INT_MAX;
  it1 = pos.begin();
  if (it1 != pos.end()) minDist = it1->first;
  if (it2 != neg.begin()) {
    it2--;
    minDist = min(minDist, abs(it2->first));
  }
  cout << minDist << endl;
  for (int i = 1; i < n; ++i) {
    it1 = pos.begin();
    while (it1 != pos.end() && (it1->first - i) <= 0) {
      tmpPair = *it1;
      pos.erase(it1);
      neg.insert(tmpPair);
      it1 = pos.begin();
    }
    tmpPair = make_pair(distInit[b[i - 1]], b[i - 1]);
    it2 = neg.find(tmpPair);
    if (it2 != neg.end()) {
      neg.erase(it2);
      tmpPair.first += (n);
      pos.insert(tmpPair);
    }
    minDist = INT_MAX;
    it2 = neg.end();
    if (it2 != neg.begin()) {
      it2--;
      minDist = abs(it2->first - i);
    }
    it2 = pos.begin();
    if (it2 != neg.end()) {
      minDist = min(minDist, it2->first - i);
    }
    cout << minDist << endl;
  }
  return 0;
}
