#include <bits/stdc++.h>
using namespace std;
int n;
multiset<int> R, L;
int a[100005], b[100005];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    a[num] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (i - a[b[i]] >= 0)
      R.insert(i - a[b[i]]);
    else
      L.insert(i - a[b[i]]);
  }
  multiset<int>::iterator it;
  for (int i = 0; i < n; i++) {
    it = R.lower_bound(i);
    int res;
    if (it != R.end()) res = (*it) - i;
    if (it != R.begin()) res = res = min(res, -1 * (*(--it) - i));
    it = L.end();
    if (L.size() > 0) res = min(res, -1 * (*(--it) - i));
    cout << res << endl;
    if (i - a[b[i]] >= 0)
      R.erase(R.find(i - a[b[i]]));
    else
      L.erase(L.find(i - a[b[i]]));
    R.insert(i + n - a[b[i]]);
  }
  return 0;
}
