#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, a[N], b[N], c[N];
multiset<int> S;
multiset<int>::iterator it;
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i], c[a[i]] = i;
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) {
    int t = i - c[b[i]];
    S.insert(t);
  }
  vector<int> r;
  for (int i = 0; i < n; i++) {
    int t = 1000000;
    it = S.lower_bound(i);
    if (it != S.end()) t = min(t, *(it)-i);
    if (it != S.begin()) t = min(t, i - *(--it));
    r.push_back(t);
    S.erase(S.find(i - c[b[i]]));
    S.insert(n - c[b[i]] + i);
  }
  for (int i = 0; i < r.size(); i++) cout << r[i] << endl;
  return 0;
}
