#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int n, a[N], b[N], inf = 1e9;
int p1[N], p2[N], dis[N];
set<pair<int, int> > s1, s2;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    p1[a[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    p2[b[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    if (i <= p1[b[i]]) {
      s1.insert(make_pair(p1[b[i]] - i, b[i]));
      dis[b[i]] = p1[b[i]] - i;
    } else {
      s2.insert(make_pair(i - p1[b[i]], b[i]));
    }
  }
  for (int i = 0; i < n; i++) {
    int v1 = inf, v2 = inf;
    if (!s1.empty()) v1 = min(v1, s1.begin()->first + i);
    if (!s2.empty()) v2 = min(v2, s2.begin()->first - i);
    printf("%d\n", min(v1, v2));
    s1.erase(make_pair(dis[b[i]], b[i]));
    s2.insert(make_pair(n - p1[b[i]] + i, b[i]));
    while (!s2.empty() and s2.begin()->first == i + 1) {
      int x = s2.begin()->second;
      dis[x] = -i - 1;
      s1.insert(make_pair(dis[x], x));
      s2.erase(s2.begin());
    }
  }
  return 0;
}
