#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int a[maxn], b[maxn];
int main() {
  int n, i, j;
  cin >> n;
  for (i = 0; i < n; i++) cin >> j, a[j] = i;
  multiset<int> s;
  for (i = 0; i < n; i++) cin >> b[i], s.insert(i - a[b[i]]);
  for (int i = 0; i < n; i++) {
    multiset<int>::iterator it = s.lower_bound(i);
    int ans = maxn;
    if (it != s.end()) ans = min(ans, *it - i);
    if (it != s.begin()) ans = min(ans, i - *(--it));
    printf("%d\n", ans);
    it = s.find(i - a[b[i]]);
    s.erase(it);
    s.insert(i - a[b[i]] + n);
  }
  return 0;
}
