#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& num) {
  num = 0;
  bool f = true;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = false;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    num = num * 10 + ch - '0';
    ch = getchar();
  }
  num = f ? num : -num;
}
int out[100];
template <class T>
inline void write(T x, char ch) {
  if (x == 0) {
    putchar('0');
    putchar(ch);
    return;
  }
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  int num = 0;
  while (x) {
    out[num++] = (x % 10);
    x = x / 10;
  }
  for (int i = (num - 1); i >= (0); i--) putchar(out[i] + '0');
  putchar(ch);
}
const double eps = 1e-8;
multiset<int> s;
int n, a[120000], x, ans, i, b[120000];
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) {
    read(x);
    a[x] = i;
  }
  for (int i = (1); i <= (n); i++) {
    read(b[i]);
    s.insert(i - a[b[i]]);
  }
  for (int i = (0); i <= (n - 1); i++) {
    set<int>::iterator it;
    it = s.lower_bound(i);
    ans = 1070000000;
    if (it != s.end()) ans = min(ans, (*it) - i);
    if (it != s.begin()) ans = min(ans, i - (*(--it)));
    s.erase(s.find(i + 1 - a[b[i + 1]]));
    s.insert(i + 1 - a[b[i + 1]] + n);
    write(ans, '\n');
  }
}
