text: //Boleyn Su's Template for Codeforces
  #include <iostream>
  #include <fstream>
  #include <sstream>
  #include <string>
  #include <vector>
  #include <list>
  #include <set>
  #include <map>
  #include <queue>
  #include <deque>
  #include <stack>
  #include <algorithm>
  #include <functional>
  #include <utility>
  #include <bitset>
  #include <cstdio>
  #include <cstdlib>
  #include <cstring>
  #include <cmath>
  #include <ctime>
  #include <climits>
  using namespace std;
  
  #define lp for(;;)
  #define rep(i,n) for (int i=0;i<(n);++i)
  #define ft(i,a,b) for (int i=(a);i<=(b);++i)
  #define fdt(i,a,b) for (int i=(a);i>=b;--i)
  #define feach(e,s,t) for (t::itr e=(s).begin();e!=(s).end();++e)
  #define whl while
  #define rtn return
  #define fl(x,y) memset((x),char(y),sizeof(x))
  #define clr(x) fl(x,0)
  #define pb push_back
  #define mp make_pair
  #define itr iterator
  #define x first
  #define y second
  #define sz(x) ((int)(x).size())
  #define len(x) ((int)(x).length())
  #define all(x) (x).begin(),(x).end()
  #define srt(x) sort(all(x))
  #define vec vector
  #define pr pair
  #define que queue
  #define prq priority_queue
  #define itr iterator
  #define prt(x) cout<<#x<<"="<<(x)<<endl
  #define asrtWA(s) do if(!(s))exit(0);whl(0)
  #define asrtTLE(s) do if(!(s))whl(1);whl(0)
  #define asrtRE(s) do if(!(s))*(int*)0=0;whl(0)
  
  typedef long long int lli;
  typedef double db;
  typedef char* cstr;
  typedef string str;
  typedef vec<int> vi;
  typedef vec<vi> vvi;
  typedef vec<bool> vb;
  typedef vec<vb> vvb;
  typedef vec<str> vs;
  typedef pr<int, int> pii;
  typedef pr<str,int> psi;
  typedef map<int,int> mii;
  typedef map<str,int> msi;
  typedef map<char,int> mci;
  typedef set<int> si;
  typedef set<str> ss;
  typedef que<int> qi;
  typedef prq<int> pqi;
  
  const int oo=(~0u)>>1;
  const lli ooll=(~0ull)>>1;
  const db inf=1e8;
  const db eps=1e-8;
  const db pi=acos(-1.0);
  
  template<typename type>inline bool cmax(type& a,const type& b){rtn a<b?a=b,true:false;}
  template<typename type>inline bool cmin(type& a,const type& b){rtn a>b?a=b,true:false;}
  template<typename type>inline type sqr(const type& x){rtn x*x;}
  int dbcmp(const db& a,const db& b){rtn (a>b+eps)-(a<b-eps);}
  int sgn(const db& x){rtn dbcmp(x,0);}
  template<typename type>inline type lb(type x){rtn x&(-x);}
  template<typename type>inline void bit_inc(vec<type>& st,int x,type inc){whl(x<sz(st))st[x]+=inc,x+=lb(x);}
  template<typename type>inline type bit_sum(const vec<type>& st,int x){type s=0;while (x>0)s+=st[x],x-=lb(x);rtn s;}
  inline void make_set(vi& set,int size){set.resize(size);rep(i,size)set[i]=i;}
  inline int find_set(vi& set,int x){if(set[x]!=x)set[x]=find_set(set,set[x]);rtn set[x];}
  inline bool union_set(vi& set,int a,int b){a=find_set(set,a),b=find_set(set,b);rtn a==b?false:set[a]=b,true;}
  
  int main()
  {
  	int n;
  	cin>>n;
  	vi a(n),b(n),A(n),B(n);
  	rep(i,n) cin>>a[i],A[--a[i]]=i;
  	rep(i,n) cin>>b[i],B[--b[i]]=i;
  	vi Ab(n);
  	rep(i,n) Ab[i]=A[b[i]];
  	vi Ab_i(n);
  	rep(i,n) Ab_i[i]=Ab[i]-i;
  	mii l,r;
  	rep(i,n) r[Ab_i[i]]++;
  	rep(k,n)
  	{
  		int output=n;
  
  		mii::itr it;
  
  		it=l.lower_bound(n-k);
  		if (it!=l.end()) cmin(output,it->first-(n-k)),it==l.begin()?it=l.end():it--;
  		else if (!l.empty()) it=l.find(l.rbegin()->first);
  		if (it!=l.end()) cmin(output,(n-k)-it->first);
  
  		it=r.lower_bound(-k);
  		if (it!=r.end()) cmin(output,it->first-(-k)),it==r.begin()?it=r.end():it--;
  		else if (!r.empty()) it=r.find(r.rbegin()->first);
  		if (it!=r.end()) cmin(output,(-k)-it->first);
  
  		cout<<output<<endl;
  		l[Ab_i[k]]++;
  		r[Ab_i[k]]--;
  		if (!r[Ab_i[k]]) r.erase(Ab_i[k]);
  	}
  }
  
  