#include <bits/stdc++.h>
using namespace std;
int mp[200000];
priority_queue<int> pq;
int bans[200000];
int a[200000];
int b[200000];
multiset<int> s;
int main() {
  int n, i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    a[i]--;
    mp[a[i]] = i;
  }
  for (i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    b[i]--;
    b[i] = mp[b[i]];
  }
  for (i = 0; i < n; i++) {
    if (b[i] >= i)
      pq.push(i - b[i]);
    else {
      s.insert(i - b[i]);
    }
  }
  int rots = 0;
  memset(bans, 1, sizeof(bans));
  bans[n] = n;
  for (i = n - 1; i >= 0; i--) {
    if (s.size() != 0) bans[i] = *s.begin() + rots;
    if (pq.size() != 0) {
      bans[i] = min(bans[i], -rots - pq.top());
      while (-pq.top() == rots) {
        s.insert(-rots);
        pq.pop();
        if (pq.size() == 0) break;
      }
    }
    rots += 1;
    multiset<int>::iterator hit;
    int rem;
    rem = (i - b[i]);
    hit = (s.find(rem));
    if (hit == s.end()) {
      printf("HERE\n");
    }
    s.erase(hit);
    pq.push(-b[i] - rots);
  }
  cout << bans[n - 1] << endl;
  for (i = 0; i + 1 < n; i++) {
    cout << bans[i] << endl;
  }
  return 0;
}
