#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const double PI = 3.14159265358979323846264338f;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const long long mod = 100000007;
const int MAXN = 50005;
inline int read() {
  int c = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    c = c * 10 + ch - '0';
    ch = getchar();
  }
  return c * f;
}
multiset<int> s;
int a[100005];
int b[100005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    x = read();
    a[x] = i;
  }
  for (int i = 0; i < n; i++) {
    b[i] = read();
    s.insert(i - a[b[i]]);
  }
  for (int i = 0; i < n; i++) {
    auto it = s.lower_bound(i);
    int ans = inf;
    if (it != s.end()) ans = min(ans, (*it) - i);
    if (it != s.begin()) ans = min(ans, i - *(--it));
    cout << ans << "\n";
    int temp = i - a[b[i]];
    s.erase(s.find(temp));
    s.insert((i + n) - a[b[i]]);
  }
  return 0;
}
