#include <bits/stdc++.h>
using namespace std;
int n, m, res;
int a[2000000], b[2000000];
int pos_a[2000000], pos_b[2000000];
multiset<int> s;
multiset<int>::iterator it;
void out() {
  for (auto i : s) cout << i << " ";
  cout << endl;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    pos_a[a[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    s.insert(i - pos_a[b[i]]);
  }
  for (int i = 0; i < n; i++) {
    res = 1e9;
    it = s.lower_bound(i);
    if (it != s.end()) {
      res = min(res, *it - i);
    }
    if (it != s.begin()) {
      res = min(res, i - *(--it));
    }
    printf("%d\n", res);
    it = s.find(i - pos_a[b[i]]);
    s.erase(it);
    s.insert(i - pos_a[b[i]] + n);
  }
  return 0;
}
