#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005];
int pos1[100005];
int main() {
  int i, j, k, l, m, n, toAdd1 = 0, toAdd2 = 0;
  cin >> n;
  for (i = n; i >= 1; i--) {
    scanf("%d", &a[i]);
    pos1[a[i]] = i;
  }
  for (i = n; i >= 1; i--) scanf("%d", &b[i]);
  multiset<int> s1, s2;
  multiset<int>::iterator it;
  for (i = 1; i <= n; i++) {
    if (pos1[b[i]] >= i)
      s1.insert(pos1[b[i]] - i);
    else
      s2.insert(i - pos1[b[i]]);
  }
  int ans1, ans2, x;
  for (i = 1; i <= n; i++) {
    if (s1.empty())
      ans1 = 5 * 100005;
    else
      ans1 = *(s1.begin()) + toAdd1;
    if (s2.empty())
      ans2 = 5 * 100005;
    else
      ans2 = *(s2.begin()) + toAdd2;
    printf("%d\n", min(ans1, ans2));
    x = b[n - i + 1];
    if (pos1[x] < n)
      s2.erase(s2.find(n - pos1[x] - toAdd2));
    else
      s1.erase(s1.find(-toAdd1));
    toAdd1--;
    toAdd2++;
    while (!s1.empty()) {
      it = s1.begin();
      if ((*it + toAdd1) < 0) {
        s1.erase(it);
        s2.insert(1 - toAdd2);
      } else
        break;
    }
    s1.insert(pos1[x] - 1 - toAdd1);
  }
  return 0;
}
