#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, a[N], b[N];
multiset<int> s;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[--x] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    s.insert(i - a[--b[i]]);
  }
  for (int i = 0; i < n; i++) {
    int ans = n;
    auto it = s.lower_bound(i);
    if (it != s.end()) ans = min(ans, *it - i);
    if (it-- != s.begin()) ans = min(ans, i - *it);
    s.erase(s.find(i - a[b[i]]));
    s.insert(n + i - a[b[i]]);
    cout << ans << endl;
  }
  return 0;
}
