#include <bits/stdc++.h>
using namespace std;
int n;
int a[100100], b[100100];
int x[100100];
int dis[100100];
struct comp {
  bool operator()(int i, int j) const {
    if (dis[i] != dis[j]) return dis[i] < dis[j];
    return i < j;
  }
};
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    x[a[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  set<int, comp> A, B;
  for (int i = 0; i < n; i++) {
    dis[i] = abs(x[b[i]] - i);
    if (i <= x[b[i]])
      A.insert(i);
    else
      B.insert(i);
  }
  int j;
  for (int i = 0; i < n; i++) {
    int one = (1 << 29);
    int two = (1 << 29);
    if (A.size()) one = dis[*A.begin()] + i;
    if (B.size()) two = dis[*B.begin()] - i;
    cout << min(one, two) << endl;
    while (B.size()) {
      j = *B.begin();
      if (dis[j] - i == 0) {
        B.erase(B.begin());
        dis[j] = -i;
        A.insert(j);
      } else
        break;
    }
    A.erase(i);
    dis[i] = n - x[b[i]] + i;
    B.insert(i);
  }
  return 0;
}
