#include <bits/stdc++.h>
using namespace std;
struct myset {
  multiset<int> s;
  int add;
  int get() {
    if (!s.size()) return (1 << 30);
    return *s.begin() + add;
  }
  void insert(int x) { s.insert(x - add); }
  void erase(int x) {
    assert(s.find(x - add) != s.end());
    s.erase(s.find(x - add));
  }
  void addval(int dlt) { add += dlt; }
  void print() {
    for (multiset<int>::iterator iter = s.begin(); iter != s.end(); ++iter)
      cerr << *iter + add << " ";
    cerr << endl;
  }
};
const int MAXN = 110000;
int rid[MAXN];
int a[MAXN];
int n;
myset up, down;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    rid[x] = i;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    a[i] = rid[a[i]];
  }
  for (int i = 0; i < n; i++) {
    if (i <= a[i]) {
      up.insert(a[i] - i);
    } else {
      down.insert(i - a[i]);
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%d\n", min(up.get(), down.get()));
    up.erase(a[i]);
    down.insert(n - a[i]);
    up.addval(1);
    down.addval(-1);
    for (; down.get() == 0;) {
      down.erase(0);
      up.insert(0);
    }
  }
  return 0;
}
