#include <bits/stdc++.h>
using namespace std;
multiset<pair<int, int> > bef, nex;
queue<pair<int, int> > remNex[200010];
int a[100010];
int p[100010];
int b[100010];
vector<int> v;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    p[a[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (p[b[i]] <= i) {
      nex.insert(pair<int, int>(i - p[b[i]], i));
      remNex[n - i].push(pair<int, int>(i - p[b[i]], i));
    } else
      bef.insert(pair<int, int>(p[b[i]] - i, i));
  }
  for (int i = 0; i < n; i++) {
    while (!remNex[i].empty()) {
      pair<int, int> tmp = remNex[i].front();
      remNex[i].pop();
      nex.erase(tmp);
      bef.insert(pair<int, int>(p[b[tmp.second]] + i, tmp.second));
    }
    while (!bef.empty() && (*bef.begin()).first - i == 0) {
      int k = (*bef.begin()).second;
      nex.insert(pair<int, int>(-i, k));
      remNex[n - p[b[k]] + i].push(pair<int, int>(-i, k));
      bef.erase(bef.begin());
    }
    int ans = 1000000000;
    if (!nex.empty()) ans = min(ans, (*nex.begin()).first + i);
    if (!bef.empty()) ans = min(ans, (*bef.begin()).first - i);
    v.push_back(ans);
  }
  cout << v[0] << endl;
  for (int i = v.size() - 1; i >= 1; i--) cout << v[i] << endl;
}
