#include <bits/stdc++.h>
using namespace std;
int n;
int a[111111], b[111111], ra[111111];
set<pair<int, int> > s;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0, _n = (int)(n); i < _n; i++) cin >> a[i], a[i]--, ra[a[i]] = i;
  for (int i = 0, _n = (int)(n); i < _n; i++) cin >> b[i], b[i]--;
  for (int i = 0, _n = (int)(n); i < _n; i++)
    s.insert(pair<int, int>(ra[b[i]] - i, i));
  for (int i = 0, _n = (int)(n); i < _n; i++) {
    int ans = 999999;
    auto x = s.upper_bound(pair<int, int>(-i, 0));
    if (x != s.end()) ans = min(ans, abs(x->first + i));
    if (x != s.begin()) x--, ans = min(ans, abs(x->first + i));
    cout << ans << endl;
    x = s.lower_bound(pair<int, int>(ra[b[i]] - i, i));
    s.erase(x);
    s.insert(pair<int, int>(x->first - n, i));
  }
  cout << endl;
  {
    int _;
    cin >> _;
  }
  return 0;
}
