#include <bits/stdc++.h>
using namespace std;
const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
int read() {
  int ret = 0, flag = 0;
  char ch;
  if ((ch = getchar()) == '-')
    flag = 1;
  else if (ch >= '0' && ch <= '9')
    ret = ch - '0';
  while ((ch = getchar()) >= '0' && ch <= '9') ret = ret * 10 + (ch - '0');
  return flag ? -ret : ret;
}
const int maxn = 100005;
int a[maxn];
int b[maxn];
multiset<int> ms;
multiset<int>::iterator msit;
int main() {
  int n, x;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    a[x] = i;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
    ms.insert(i - a[b[i]]);
  }
  for (int i = 0; i < n; ++i) {
    msit = ms.lower_bound(i);
    int ans = 0x3f3f3f3f;
    if (msit != ms.end()) ans = min(ans, *msit - i);
    if (msit != ms.begin()) ans = min(ans, i - *(--msit));
    printf("%d\n", ans);
    msit = ms.find(i - a[b[i]]);
    ms.erase(msit);
    ms.insert(i - a[b[i]] + n);
  }
}
