#include <bits/stdc++.h>
const long double pi = fabsl(atan2l(0.0, -1.0));
const long double eps = 1e-9;
const int inf = 1 << 28;
using namespace std;
int n;
int a[123123], b[123123], p[2][123132];
void load() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    a[i]--;
    p[0][a[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    b[i]--;
    p[1][b[i]] = i;
  }
}
int toadd;
int check(int q) { return abs(q + toadd); }
multiset<int> all;
int res[123123];
void solve() {
  for (int i = 0; i < n; i++) all.insert(p[0][i] - p[1][i]);
  toadd = 0;
  for (int i = 0; i < n; i++) {
    multiset<int>::iterator it = all.upper_bound(-toadd);
    int result = 1 << 28;
    if (it == all.end())
      result = check(*all.rbegin());
    else if (it == all.begin())
      result = check(*all.begin());
    else {
      it--;
      result = check(*it);
      it++;
      result = min(result, check(*it));
    }
    res[(n - i) % n] = result;
    it = all.find(p[0][b[n - i - 1]] - (n - 1) - toadd);
    assert(it != all.end());
    all.erase(it);
    toadd--;
    all.insert(p[0][b[n - i - 1]] - toadd);
  }
  for (int i = 0; i < n; i++) printf("%d\n", res[i]);
}
int main() {
  load();
  solve();
  return 0;
}
