#include <bits/stdc++.h>
using namespace std;
const int MAX = 100001;
const long long MOD = 1000000007LL;
int a[MAX];
int b[MAX];
int pos[MAX];
multiset<int> mark;
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", a + i);
    pos[a[i]] = i;
  }
  for (int i = 1; i <= N; ++i) {
    scanf("%d", b + i);
    mark.insert(i - pos[b[i]]);
  }
  for (int i = 0; i < N; ++i) {
    multiset<int>::iterator it = mark.lower_bound(i);
    int ret = 1 << 25;
    if (it != mark.end()) ret = min(ret, (*it) - i);
    if (it != mark.begin()) ret = min(ret, i - *(--it));
    cout << ret << endl;
    mark.erase(mark.find(i + 1 - pos[b[i + 1]]));
    mark.insert(i + 1 - pos[b[i + 1]] + N);
  }
  return 0;
}
