#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005], b[100005];
int p[100005];
set<int> s;
map<int, int> mp;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    p[a[i]] = i;
  }
  int ans = 100005;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    int k = i - p[b[i]];
    mp[k]++;
    s.insert(k);
    ans = min(ans, abs(k));
  }
  printf("%d\n", ans);
  for (int i = 1; i < n; i++) {
    ans = 100005;
    int k = i + n - p[b[i]];
    int tmp = i - p[b[i]];
    if (mp[tmp] > 0) {
      mp[tmp]--;
      if (mp[tmp] == 0) s.erase(tmp);
    }
    s.insert(k);
    mp[k]++;
    set<int>::iterator it = s.lower_bound(i);
    if (it != s.begin()) {
      --it;
      ans = min(ans, i - *it);
      it++;
    }
    if (it != s.end()) {
      ans = min(ans, *it - i);
    }
    printf("%d\n", ans);
  }
  return 0;
}
