#include <bits/stdc++.h>
using namespace std;
long n, a[200000], ps[200000], b[200000];
multiset<long> sett;
multiset<long>::iterator it;
long ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ps[a[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    sett.insert(i - ps[b[i]]);
  }
  for (int i = 0; i < n; i++) {
    ans = n;
    it = sett.lower_bound(i);
    if (it != sett.end()) ans = min(ans, (*it) - i);
    if (it != sett.begin()) {
      it--;
      ans = min(ans, i - (*it));
    }
    cout << ans << endl;
    it = sett.find(i - ps[b[i]]);
    sett.erase(it);
    sett.insert(i - ps[b[i]] + n);
  }
  cin.get();
  cin.get();
  return 0;
}
