#include <cstdio>
using namespace std;

int n, k;
char s[100001];
int wposa[100001], wposai, wposan;
int wposb[100001], wposbi, wposbn;

int main() {
    int i;
    int fmaxa, cmaxa, changesa;
    int fmaxb, cmaxb, changesb;

    scanf("%d %d", &n, &k);
    scanf("%s", s);

    fmaxa = 0; cmaxa = 0; wposai = 0; wposan = 0;
    fmaxb = 0; cmaxb = 0; wposbi = 0; wposbn = 0;
    for (i = 0; i < n; ++i) {
        if (s[i] != 'a') {
            wposa[wposan++] = i;
            if (wposan > k)
                cmaxa = i - 1 - wposa[wposai++];
        }
        if (s[i] != 'b') {
            wposb[wposbn++] = i;
            if (wposbn > k)
                cmaxb = i - 1 - wposb[wposbi++];
        }
        ++cmaxb;
        ++cmaxa;
        if (fmaxa < cmaxa)
            fmaxa = cmaxa;
        if (fmaxb < cmaxb)
            fmaxb = cmaxb;
    }
    if (fmaxa > fmaxb)
        printf("%d\n", fmaxa);
    else
        printf("%d\n", fmaxb);

    return 0;
}


#include<algorithm>
#include<iostream>
#include<fstream>
#include<utility>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<queue>
#include<map>
#include<set>
using namespace std;
int n, k,ans=0;
string s;
void func(char a)
{
	int c=0,K=k,last=0;
	for(int i=0;i<n;i++){
		if (s[i] == a)c++;
		else {
			if(!K){
				for (int j=last; ;j++){
					c--;
					if (s[j] != a)
					{
						K++;
						last = j + 1;
						break;
					}
			     }
			}
			K--;
			c++;
		}
		ans=max(ans,c);
	}
}
int main()
{
	cin>>n>>k>>s;
	func('a');
	func('b');
	cout <<ans<<endl;
}


#include<iostream>
#include<vector>
#include<fstream>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<list>
#include<stack>
#include<iomanip>
#include<queue>
#include<ctime>
#include<cmath>

using namespace std;

#define forn(i,n) for(int i = 0; i < (int)n; i++)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define vi vector<int>
#define vit vector<int>::iterator
#define vvi vector< vector<int> >
#define viit vector< vector<int> >::iterator
#define vll vector<long long>
#define vllit vector<long long>::iterator
#define vvll vector< vector<long long> >
#define vvllit vector< vector<long long> >::iterator
#define all(a) a.begin(), a.end()
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) a.size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound

const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-8;
const int INF = 2000000000;
const long long INFL = 2000000000000000;
const double INF_DOUBLE = 2000000000.0;

typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
//%I64d

template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
//memset(v,0,sizeof(v));
string int2string(int x)
{
	string result;

	if(x == 0)
		result = "0";

	while(x > 0)
	{
		int r = x%10;
		char c = r + '0';
		result += c;
		x /= 10;
	}

	int size = result.size();
	for(int i = 0; i < size/2; i++)
		swap(result[i],result[size - i - 1]);

	return result;
}
struct edge{
	ll begin, end, length;
};
bool noDif(string &f, string &s)
{
	int size = f.size();
	int cntDif = 0;
	for(int i = 0; i < size && cntDif < 2; i++)
	{
		if(f[i] != s[i])
			cntDif++;
	}
	if(cntDif > 1)
		return false;
	return true;
}

double square(double x)
{
	return x*x;
}
ll square(ll x)
{
	return x*x;
}
double dist(double x1, double y1, double x2, double y2)
{
	return sqrt( square(x2 - x1) + square(y2 - y1) );
}

vector<pll> c;

double sumD(double x, double y)
{
	double sum = 0;
	int cSize = c.size();

	forn(i,cSize)
	{
		double d = dist(x,y,c[i].first,c[i].second);
		if(d == 0)
			sum += 1;
		else
			sum += 1/square((double)ceil(d));
	}

	return sum;
}
struct item{
	bool used;
	double left, right;
};

vector<int> cntA;
int n, k;
bool can(int len)
{
	if(len == 0)
		return true;
	if(len > n)
		return false;
	int begin = 0, end = begin + len - 1;

	while(end < n)
	{
		int cnt_a = 0;
		if(begin == 0)
			cnt_a = cntA[end];
		else
			cnt_a = cntA[end] - cntA[begin - 1];

		int cnt_b = len - cnt_a;

		if(cnt_a <= k || cnt_b <= k)
			return true;

		begin++;
		end++;
	}
	return false;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	cin >> n >> k;
	cntA.assign(n,0);
	string s;
	cin >> s;
	forn(i,n)
	{
		if(i == 0)
		{
			if(s[i] == 'a')
				cntA[i] = 1;
		}
		else
		{
			int curCnt = 0;
			if(s[i] == 'a')
				curCnt = 1;
			cntA[i] = cntA[i-1] + curCnt;
		}
	}

	int left = 0, right = n;
	forn(i,100)
	{
		int mid = (left + right)/2;
		if(can(mid))
			left = mid;
		else
			right = mid;
	}

	if(can(right))
		cout << right;
	else
		cout << right - 1;
}


#include<iostream>
#include<vector>
#include<fstream>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<list>
#include<stack>
#include<iomanip>
#include<queue>
#include<ctime>
#include<cmath>

using namespace std;

#define forn(i,n) for(int i = 0; i < (int)n; i++)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define vi vector<int>
#define vit vector<int>::iterator
#define vvi vector< vector<int> >
#define viit vector< vector<int> >::iterator
#define vll vector<long long>
#define vllit vector<long long>::iterator
#define vvll vector< vector<long long> >
#define vvllit vector< vector<long long> >::iterator
#define all(a) a.begin(), a.end()
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) a.size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound

const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-8;
const int INF = 2000000000;
const long long INFL = 2000000000000000;
const double INF_DOUBLE = 2000000000.0;

typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
//%I64d

template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
//memset(v,0,sizeof(v));
string int2string(int x)
{
	string result;

	if(x == 0)
		result = "0";

	while(x > 0)
	{
		int r = x%10;
		char c = r + '0';
		result += c;
		x /= 10;
	}

	int size = result.size();
	for(int i = 0; i < size/2; i++)
		swap(result[i],result[size - i - 1]);

	return result;
}
struct edge{
	ll begin, end, length;
};
bool noDif(string &f, string &s)
{
	int size = f.size();
	int cntDif = 0;
	for(int i = 0; i < size && cntDif < 2; i++)
	{
		if(f[i] != s[i])
			cntDif++;
	}
	if(cntDif > 1)
		return false;
	return true;
}

double square(double x)
{
	return x*x;
}
ll square(ll x)
{
	return x*x;
}
double dist(double x1, double y1, double x2, double y2)
{
	return sqrt( square(x2 - x1) + square(y2 - y1) );
}

vector<pll> c;

double sumD(double x, double y)
{
	double sum = 0;
	int cSize = c.size();

	forn(i,cSize)
	{
		double d = dist(x,y,c[i].first,c[i].second);
		if(d == 0)
			sum += 1;
		else
			sum += 1/square((double)ceil(d));
	}

	return sum;
}
struct item{
	bool used;
	double left, right;
};

vector<int> cntA;
int n, k;
bool can(int len)
{
	if(len == 0)
		return true;
	if(len > n)
		return false;
	int begin = 0, end = begin + len - 1;

	while(end < n)
	{
		int cnt_a = 0;
		if(begin == 0)
			cnt_a = cntA[end];
		else
			cnt_a = cntA[end] - cntA[begin - 1];

		int cnt_b = len - cnt_a;

		if(cnt_a <= k || cnt_b <= k)
			return true;

		begin++;
		end++;
	}
	return false;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	cin >> n >> k;
	cntA.assign(n,0);
	string s;
	cin >> s;
	forn(i,n)
	{
		if(i == 0)
		{
			if(s[i] == 'a')
				cntA[i] = 1;
		}
		else
		{
			int curCnt = 0;
			if(s[i] == 'a')
				curCnt = 1;
			cntA[i] = cntA[i-1] + curCnt;
		}
	}

	int left = 0, right = n;
	forn(i,100)
	{
		int mid = (left + right)/2;
		if(can(mid))
			left = mid;
		else
			right = mid;
	}

	if(right < n)
	{
		if(can(right))
			cout << right;
		else
			cout << right - 1;
	}
	else
		cout << right;
}


#include<iostream>
#include<vector>
#include<fstream>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<list>
#include<stack>
#include<iomanip>
#include<queue>
#include<ctime>
#include<cmath>

using namespace std;

#define forn(i,n) for(int i = 0; i < (int)n; i++)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define vi vector<int>
#define vit vector<int>::iterator
#define vvi vector< vector<int> >
#define viit vector< vector<int> >::iterator
#define vll vector<long long>
#define vllit vector<long long>::iterator
#define vvll vector< vector<long long> >
#define vvllit vector< vector<long long> >::iterator
#define all(a) a.begin(), a.end()
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) a.size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound

const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-8;
const int INF = 2000000000;
const long long INFL = 2000000000000000;
const double INF_DOUBLE = 2000000000.0;

typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
//%I64d

template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
//memset(v,0,sizeof(v));
string int2string(int x)
{
	string result;

	if(x == 0)
		result = "0";

	while(x > 0)
	{
		int r = x%10;
		char c = r + '0';
		result += c;
		x /= 10;
	}

	int size = result.size();
	for(int i = 0; i < size/2; i++)
		swap(result[i],result[size - i - 1]);

	return result;
}
struct edge{
	ll begin, end, length;
};
bool noDif(string &f, string &s)
{
	int size = f.size();
	int cntDif = 0;
	for(int i = 0; i < size && cntDif < 2; i++)
	{
		if(f[i] != s[i])
			cntDif++;
	}
	if(cntDif > 1)
		return false;
	return true;
}

double square(double x)
{
	return x*x;
}
ll square(ll x)
{
	return x*x;
}
double dist(double x1, double y1, double x2, double y2)
{
	return sqrt( square(x2 - x1) + square(y2 - y1) );
}

vector<pll> c;

double sumD(double x, double y)
{
	double sum = 0;
	int cSize = c.size();

	forn(i,cSize)
	{
		double d = dist(x,y,c[i].first,c[i].second);
		if(d == 0)
			sum += 1;
		else
			sum += 1/square((double)ceil(d));
	}

	return sum;
}
struct item{
	bool used;
	double left, right;
};

vector<int> cntA;
int n, k;
bool can(int len)
{
	if(len == 0)
		return true;
	if(len > n)
		return false;
	int begin = 0, end = begin + len - 1;

	while(end < n)
	{
		int cnt_a = 0;
		if(begin == 0)
			cnt_a = cntA[end];
		else
			cnt_a = cntA[end] - cntA[begin - 1];

		int cnt_b = len - cnt_a;

		if(cnt_a <= k || cnt_b <= k)
			return true;

		begin++;
		end++;
	}
	return false;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	cin >> n >> k;
	cntA.assign(n,0);
	string s;
	cin >> s;
	forn(i,n)
	{
		if(i == 0)
		{
			if(s[i] == 'a')
				cntA[i] = 1;
		}
		else
		{
			int curCnt = 0;
			if(s[i] == 'a')
				curCnt = 1;
			cntA[i] = cntA[i-1] + curCnt;
		}
	}

	int left = 0, right = n-1;
	forn(i,100)
	{
		int mid = (left + right)/2;
		if(can(mid))
			left = mid;
		else
			right = mid;
	}

	if(can(right))
		cout << right;
	else
		cout << right - 1;
}


#include<iostream>
#include<vector>
#include<fstream>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<list>
#include<stack>
#include<iomanip>
#include<queue>
#include<ctime>
#include<cmath>

using namespace std;

#define forn(i,n) for(int i = 0; i < (int)n; i++)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define vi vector<int>
#define vit vector<int>::iterator
#define vvi vector< vector<int> >
#define viit vector< vector<int> >::iterator
#define vll vector<long long>
#define vllit vector<long long>::iterator
#define vvll vector< vector<long long> >
#define vvllit vector< vector<long long> >::iterator
#define all(a) a.begin(), a.end()
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) a.size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound

const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-8;
const int INF = 2000000000;
const long long INFL = 2000000000000000;
const double INF_DOUBLE = 2000000000.0;

typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
//%I64d

template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
//memset(v,0,sizeof(v));
string int2string(int x)
{
	string result;

	if(x == 0)
		result = "0";

	while(x > 0)
	{
		int r = x%10;
		char c = r + '0';
		result += c;
		x /= 10;
	}

	int size = result.size();
	for(int i = 0; i < size/2; i++)
		swap(result[i],result[size - i - 1]);

	return result;
}
struct edge{
	ll begin, end, length;
};
bool noDif(string &f, string &s)
{
	int size = f.size();
	int cntDif = 0;
	for(int i = 0; i < size && cntDif < 2; i++)
	{
		if(f[i] != s[i])
			cntDif++;
	}
	if(cntDif > 1)
		return false;
	return true;
}

double square(double x)
{
	return x*x;
}
ll square(ll x)
{
	return x*x;
}
double dist(double x1, double y1, double x2, double y2)
{
	return sqrt( square(x2 - x1) + square(y2 - y1) );
}

vector<pll> c;

double sumD(double x, double y)
{
	double sum = 0;
	int cSize = c.size();

	forn(i,cSize)
	{
		double d = dist(x,y,c[i].first,c[i].second);
		if(d == 0)
			sum += 1;
		else
			sum += 1/square((double)ceil(d));
	}

	return sum;
}
struct item{
	bool used;
	double left, right;
};

int main()
{
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int n, k;
	cin >> n >> k;
	vector<int> cntA(n);
	string s;
	cin >> s;
	forn(i,n)
	{
		if(i == 0)
		{
			if(s[i] == 'a')
				cntA[i] = 1;
		}
		else
		{
			int curCnt = 0;
			if(s[i] == 'a')
				curCnt = 1;
			cntA[i] = cntA[i-1] + curCnt;
		}
	}

	int result = k;

	for(int begin = 0; begin < n; begin++)
	{
		for(int end = begin + result; end < n; end++)
		{
			int cnt_a = 0;
			if(begin == 0)
				cnt_a = cntA[end];
			else
				cnt_a = cntA[end] - cntA[begin - 1];
			int len = end - begin + 1,
				cnt_b = len - cnt_a;

			if(cnt_a <= k || cnt_b <= k)
				result = len;
		}
	}

	cout << result;
}


#include <algorithm>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <cmath>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include <functional>
#include "time.h"
using namespace std;
#define SZ(x) (int)x.size()
#define FOR(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define REP(i,n) FOR(i,0,n-1)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define ALL(a) (a).begin(),(a).end()
#define FORE(i,t) for(i=t.begin();i!=t.end();++i)
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef deque<int> DI;
typedef deque<string> DS;
typedef long long i64;
#define PI 3.14159265358979323
#define DEGTORAD(x) (double)x * 3.14159265358979323846264338327950288 / 180.0
#define RADTODEG(x) (double)x * 180 / 3.14159265358979323846264338327950288
#define prt if(1)printf
typedef pair< int, int > PII;
template <typename T> string tostr(const T& t) { ostringstream os; os << t; return os.str(); }
#define ARRTOV(a,v) (v.assign(a,a+sizeof(a)/sizeof(a[0])))
#define SAFEMOD(a,b) (((a%b)+b)%b)
#define SQR(x) ((x)*(x))
#define EPS 1e-9
#define POW(x,y) pow((double)(x),(double)(y))
#define LL_MAX 9223372036854775807LL
typedef pair< i64, i64 > PLL;
typedef pair< string, string > PSS;
typedef pair< char, char > PCC;

const int MX = 100010;
int N,K;
string S;
int cntA[MX];
int cntB[MX];

int calc(int start, int end) {
  int ca = cntA[end];
  if (start - 1 >= 0)
    ca -= cntA[start-1];
  int cb = cntB[end];
  if (start - 1 >= 0)
    cb -= cntB[start-1];
  int ret = min(ca,cb);
  return ret;
}

int search(int start) {
  const int interval = 1000;
  int end = start;
  for(end = start; end < N; end += interval) {
    int x = calc(start,end);
    if (x > K)
      break;
  }
  if (end >= N)
    end = N-1;

  while(calc(start,end) <= K && end < N) {
    ++end;
  }
  if (end == N)
    --end;

  if (calc(start,end) <= K)
    return end-start+1;

  while(calc(start,end) > K && end > start) {
    --end;
  }

  if (calc(start,end) <= K)
    return end-start+1;

  return -1;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("354_C.in", "r", stdin);
#endif

  cin>>N>>K;
  cin>>S;
  memset(cntA,0,sizeof cntA);
  memset(cntB,0,sizeof cntB);
  REP(i,N) {
    if (i==0) {
      cntA[i] = S[i] == 'a';
      cntB[i] = S[i] == 'b';
    }
    else {
      cntA[i] = cntA[i-1] + (S[i]=='a');
      cntB[i] = cntB[i-1] + (S[i]=='b');
    }
  }

  int ans = 0;
  REP(i,N) {
    int x = search(i);
    ans = max(ans,x);
  }

  cout<<ans;

byebye:;
  return 0;
}


#define _CRT_SECURE_NO_WARNINGS

//#pragma comment(linker, "/STACK:66777216")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <string>
#include <string>
#include <stack>

using namespace std;

#define ldouble long double
#define ll long long
#define ull unsigned long long
#define mk make_pair
#define linf 2e16
#define inf 2e9
#define Size 500005
#define nl nullptr
#define eps 0.00000001
#define TL clock() * 1.0 / CLOCKS_PER_SEC

ll N, K;
vector<ll> A[2];
bool B[Size];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);

	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		char a;
		cin >> a;
		B[i] = a - 'a';
		A[a - 'a'].push_back(i);
	}

	ll ans = 0;

	for (int t = 0; t < 2; t++) {

		ll beg = 0;
		ll k = K;
		ll cur = 0;

		for (int en = 0; en < N; en++) {
			if (B[en] != t) {
				if (k > 0)
					k--;
				else {
					beg = A[!(bool)(t)][cur++] + 1;
				}
			}
			ans = max(ans, en - beg + 1);
		}

	}

	cout << ans << "\n";

	return 0;
}


//
//  main.cpp
//  C
//
//  Created by 胡佳成 on 16/5/26.
//  Copyright © 2016年 胡佳成. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=100000;
char s[maxn+5];
int n,k;
int solve(char ch){
    int l=0,r=0;
    int num=0;
    int len=0;
    while(r<n){
        if(r!=0){
            if(s[l++]==ch) num--;
        }
        while(r<n&&num<=k){
            if(s[r]==ch){
                if(num!=k)
                    num++;
                else
                    break;
            }
            r++;
        }
        len=max(len,r-l);
    }
    return len;
}
int main(int argc, const char * argv[]) {
    scanf("%d%d%s",&n,&k,s);
    printf("%d\n",max(solve('a'),solve('b')));
    return 0;
}


//
//  main.cpp
//  C
//
//  Created by 胡佳成 on 16/5/26.
//  Copyright © 2016年 胡佳成. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=100000;
char s[maxn+5];
int n,k;
int solve(char ch){
    int l=0,r=0;
    int num=0;
    int len=0;
    while(r<n&&num<=k){
        if(s[r]==ch){
            if(num!=k)
                num++;
            else
                break;
        }
        r++;
    }
    len=max(len,r-l);
    while(r<n){
        if(s[l++]==ch) num--;
        if(s[r++]==ch) num++;
        while(r<n&&num<=k){
            if(s[r]==ch){
                if(num!=k)
                    num++;
                else
                    break;
            }
            r++;
        }
        len=max(len,r-l);
    }
    return len;
}
int main(int argc, const char * argv[]) {
    scanf("%d%d%s",&n,&k,s);
    printf("%d\n",max(solve('a'),solve('b')));
    return 0;
}


#include"iostream"
#include"algorithm"
using namespace std;

char c[100005];
int a[100005];
int b[100005];
int main()
{
	int n,t;
	int i, j;
	int ans;
	while (scanf("%d%d", &n,&t) != EOF)
	{
		ans = 0;
		scanf("%s", &c);
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		if (c[0] == 'a')
			a[1] = 1;
		else
			b[1] = 1;
		for (i = 2; i <= n; i++)
		{
			if (c[i-1] == 'a')
			{
				a[i] = a[i - 1] + 1;
				b[i] = b[i - 1];
			}
			else
			{
				b[i] = b[i - 1] + 1;
				a[i] = a[i - 1];
			}
		}

		for (i = 1; n-i+1>ans; i++)
		{
			j = n;
			while (j > i&&j-i+1>ans)
			{
				int temp = min(a[j] - a[i - 1], b[j] - b[i - 1]);
				if (temp <= t && j-i+1>ans)
				{
					ans = j - i + 1;
					break;
				}
				j--;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include"iostream"
#include"algorithm"
using namespace std;

char c[100005];
int a[100005];
int b[100005];
int main()
{
	int n,t;
	int i, j;
	int ans;
	while (scanf("%d%d", &n,&t) != EOF)
	{
		ans = 0;
		scanf("%s", &c);
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		if (c[0] == 'a')
			a[1] = 1;
		else
			b[1] = 1;
		for (i = 2; i <= n; i++)
		{
			if (c[i-1] == 'a')
			{
				a[i] = a[i - 1] + 1;
				b[i] = b[i - 1];
			}
			else
			{
				b[i] = b[i - 1] + 1;
				a[i] = a[i - 1];
			}
		}

		for (i = 1; n-i+1>=ans; i++)
		{
			j = n;
			while (j >= i&&j-i+1>ans)
			{
				int temp = min(a[j] - a[i - 1], b[j] - b[i - 1]);
				if (temp <= t && j-i+1>ans)
				{
					ans = j - i + 1;
					break;
				}
				j--;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include"iostream"
#include"algorithm"
using namespace std;

char c[100005];
int a;
int b;
int main()
{
	int n,t;
	int i, j,k;
	int ans;
	while (scanf("%d%d", &n,&t) != EOF)
	{
		ans = 0;
		scanf("%s", &c);
		a = 0;
		b = 0;
		i = 0; j = 0;
		while(j < n)
		{
			if (c[j] == 'a')
				a++;
			else
				b++;
			while (min(a, b)>t)
			{
				if (c[i] == 'a')
					a--;
				else
					b--;
				i++;
			}

			if (j - i + 1 > ans)
				ans = j - i + 1;
			j++;

		}

		printf("%d\n", ans);
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include<stdlib.h>
#include <iostream>

using namespace std;

#define max(a,b) a>b?a:b

int a[100001];
char str[100001];
int main()
{
	int i,j;
	int n,m;
	int t1,t2,k;
	char t;
	while(~scanf("%d%d",&n,&m))
	{
		scanf("%s",str);
		int len=strlen(str);
		t=str[0];
		a[1]=1;
		j=1;
		for(i=1;i<len;i++)
		{
			if(str[i]==t)
			{
				a[j]++;
			}
			else
			{
				t=str[i];
				j++;
				a[j]=1;
			}
		}
		int Max=0;

		for(i=1;i<=j;i++)
		{
			t2=a[i];
			t1=m;
			for(k=i+1;k<=j;k++)
			{
				if((k%2)!=(i%2))
				{
					if(a[k]<=t1)
					{
						t2+=a[k];
						t1-=a[k];
					}
					else
					{
						t2+=t1;
						break;
					}
				}
				else
				{
					t2+=a[k];
				}
			}
			Max=max(Max,t2);
		}
		printf("%d\n",Max);
	}
	return 0;
}


#include"iostream"
#include"algorithm"
using namespace std;

char c[100005];
int a[100005];
int b[100005];
int main()
{
	int n,t;
	int i, j;
	int ans;
	while (scanf("%d%d", &n,&t) != EOF)
	{
		ans = 0;
		scanf("%s", &c);
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		if (c[0] == 'a')
			a[1] = 1;
		else
			b[1] = 1;
		for (i = 2; i <= n; i++)
		{
			if (c[i-1] == 'a')
			{
				a[i] = a[i - 1] + 1;
				b[i] = b[i - 1];
			}
			else
			{
				b[i] = b[i - 1] + 1;
				a[i] = a[i - 1];
			}
		}

		for (i = 1; n-i+1>ans; i++)
		{
			j = n;
			while (j >= i&&j-i+1>ans)
			{
				int temp = min(a[j] - a[i - 1], b[j] - b[i - 1]);
				if (temp <= t && j-i+1>ans)
				{
					ans = j - i + 1;
					break;
				}
				j--;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include"iostream"
#include"algorithm"
using namespace std;

char c[100005];
int a[100005];
int b[100005];
int main()
{
	int n,t;
	int i, j,k;
	int ans;
	while (scanf("%d%d", &n,&t) != EOF)
	{
		ans = 0;
		scanf("%s", &c);
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		if (c[0] == 'a')
			a[1] = 1;
		else
			b[1] = 1;
		for (i = 2; i <= n; i++)
		{
			if (c[i-1] == 'a')
			{
				a[i] = a[i - 1] + 1;
				b[i] = b[i - 1];
			}
			else
			{
				b[i] = b[i - 1] + 1;
				a[i] = a[i - 1];
			}
		}

		for (k = n; k >= 1; k--)
		{
			for (i =0; i + k <= n; i++)
			{
				if (min(a[i + k] - a[i], b[i + k] - b[i]) <= t)
				{
					ans = k;
					break;
				}
			}
			if (ans)
				break;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;
ll a[200];
int main()
{
	int k, n;
	cin >> n >> k;
	string s;
	cin >> s;

	ll tota = 0,mxa=0;
	ll mb = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (mb>0 && tota == 0)
		{
			mb = 0;
		}
		if (s[i] == 'a')
		{
			tota++;
		}
		else
		{
			mb++;

			if (mb>k)
			{
				mxa = max(mxa, tota);
				tota = 0;
				mb = 0;
			}
			else
			{
				tota++;
			}
		}
		mxa = max(mxa, tota);
	}
	ll totb = 0, mxb = 0;
	ll ma = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (ma>0 && totb == 0)
		{
			ma = 0;
		}
		if (s[i] == 'b')
		{
			totb++;
		}
		else
		{
			ma++;

			if (ma>k)
			{
				mxb = max(mxb, totb);
				totb = 0;
			}
			else
			{
				totb++;
			}
		}
		mxb = max(mxb, totb);
	}
	cout << max(mxa,mxb);
	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;
ll a[200];
int main()
{
	ll k, n;
	cin >> n >> k;
	string s;
	cin >> s;

	ll tota = 0,mxa=0;
	ll mb = 0;
	ll lastb = -1;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'a')
		{
			tota++;
		}
		if (s[i] == 'b')
		{

			for (int j = i; j < s.length(); j++)
			{
				if (s[j] == 'b')
				{
					mb++;
					if (mb>k)
					{
						mb = 0;
						break;
					}
					tota++;
				}
				else
				{
					tota++;
				}

			}
			mxa = max(mxa, tota);
			tota = 0;
			lastb = i;
		}
		mxa = max(mxa, tota);
	}
	//system("pause");
	ll totb = 0, mxb = 0;
	ll ma = 0;
	ll lasta = -1;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'b')
		{
			totb++;
		}
		if (s[i] == 'a')
		{
			totb = (i - (lasta + 1));
			for (int j = i; j < s.length(); j++)
			{
				if (s[j] == 'a')
				{
					ma++;
					if (ma>k)
					{
						ma = 0;
						break;
					}
					totb++;
				}
				else
				{
					totb++;
				}

			}
			mxb = max(mxb, totb);
			totb = 0;
			lasta = i;
		}
		mxb = max(mxb, totb);
	}
	cout << max(mxa,mxb);
	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#define ll long long
using namespace std;
ll a[200];
int main()
{
	ll k, n;
	cin >> n >> k;
	string s;
	cin >> s;

	ll tota = 0, mxa = 0;
	ll mb = 0;
	ll lastb = -1;
	queue <ll> w;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'a')
		{
			tota++;
		}
		if (s[i] == 'b')
		{

			ll tt = tota;
			int j = i;
			for (; j < s.length(); j++)
			{
				if (s[j] == 'b')
				{
					w.push(tt);
					tt = 0;
					mb++;
					if (mb>k)
					{
						mb--;
						tota--;
						if (!w.empty())
						{
							tota -= (w.front());
							w.pop();
						}
					}
					tota++;
				}
				else
				{
					tota++;
					tt++;
				}
				mxa = max(mxa, tota);

			}
			if (j == n)
			{
				break;
			}
		}
		mxa = max(mxa, tota);

	}
	//system("pause");
	ll totb = 0, mxb = 0;
	ll ma = 0;
	ll lasta = -1;
	queue <ll> ww;

	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'b')
		{
			totb++;
		}
		if (s[i] == 'a')
		{
			ll hh = totb;
			//cout << " totb   " << totb << endl;;
			int j = i;
			for (; j < s.length(); j++)
			{
				if (s[j] == 'a')
				{
					ww.push(hh);
					//cout << "hh   " << hh << endl;
					hh = 0;
					ma++;
					if (ma>k)
					{
						ma--;
						totb--;
						if (!ww.empty())
						{
							totb -= (ww.front());
							ww.pop();
						}
					}
					totb++;
				}
				else
				{
					totb++;
					hh++;
				}
				mxb = max(mxb, totb);
			}
			if (j == n)
			{
				break;
			}
		}
		mxb = max(mxb, totb);
	}
	cout << max(mxa, mxb);
	//system("pause");
	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;
ll a[200];
int main()
{
	ll k, n;
	cin >> n >> k;
	string s;
	cin >> s;

	ll tota = 0,mxa=0;
	ll mb = 0;
	ll lastb = -1;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'b')
		{

			tota = (i - (lastb+1));

			for (int j = i; j < s.length(); j++)
			{
				if (s[j] == 'b')
				{
					mb++;
					if (mb>k)
					{
						mb = 0;
						break;
					}
					tota++;
				}
				else
				{
					tota++;
				}

			}
			mxa = max(mxa, tota);
			lastb = i;
		}
	}
	//system("pause");
	ll totb = 0, mxb = 0;
	ll ma = 0;
	ll lasta = -1;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'a')
		{
			totb = (i - (lasta + 1));
			for (int j = i; j < s.length(); j++)
			{
				if (s[j] == 'a')
				{
					ma++;
					if (ma>k)
					{
						ma = 0;
						break;
					}
					totb++;
				}
				else
				{
					totb++;
				}

			}
			mxb = max(mxb, totb);
			lasta = i;
		}
	}
	cout << max(mxa,mxb);
	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;
ll a[200];
int main()
{
	ll k, n;
	cin >> n >> k;
	string s;
	cin >> s;

	ll tota = 0, mxa = 0;
	ll mb = 0;
	ll lastb = -1;
	for (int i = 0; i < s.length(); i++)
	{
		int j = i;
		if (s[i] == 'a')
		{
			tota++;
		}
		if (s[i] == 'b')
		{

			for (; j < s.length(); j++)
			{
				if (s[j] == 'b')
				{
					mb++;
					if (mb>k)
					{
						mb = 0;
						break;
					}
					tota++;
				}
				else
				{
					tota++;
				}

			}
			mxa = max(mxa, tota);
			tota = 0;
			lastb = i;
		}
		mxa = max(mxa, tota);
		if (j == n)
		{
			break;
		}
	}
	//system("pause");
	ll totb = 0, mxb = 0;
	ll ma = 0;
	ll lasta = -1;
	for (int i = 0; i < s.length(); i++)
	{
		int j = i;
		if (s[i] == 'b')
		{
			totb++;
		}
		if (s[i] == 'a')
		{
			totb = (i - (lasta + 1));
			for (int j = i; j < s.length(); j++)
			{
				if (s[j] == 'a')
				{
					ma++;
					if (ma>k)
					{
						ma = 0;
						break;
					}
					totb++;
				}
				else
				{
					totb++;
				}

			}
			mxb = max(mxb, totb);
			totb = 0;
			lasta = i;
		}
		mxb = max(mxb, totb);
		if (j == n)
		{
			break;
		}
	}
	cout << max(mxa, mxb);
	return 0;
}


#pragma comment(linker, "/STACK:99777216")
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>

#define M_PI 3.14159265358979323846

using namespace std;

typedef unsigned __int64 ui;
typedef __int64 si;
typedef long long ll;

string s;
//map<char, int> f;

int main()
{
	ios_base::sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	cin >> s;
	ll count = 0;
	for (int l = 0; l < n; ++l)
	{
		int ac = 0, bc = 0;
		int pc = count;
		for (int r = l; r < n; ++r)
		{
			if (s[r] == 'a')
				++ac;
			else
				++bc;
			if (ac > k && bc > k)
				break;
			count = max(count, (ll) r - l + 1);
		}
		if (pc == count)
			break;
	}
	cout << count << endl;
	return 0;
}


#pragma comment(linker, "/STACK:99777216")
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>

#define M_PI 3.14159265358979323846

using namespace std;

typedef unsigned __int64 ui;
typedef __int64 si;
typedef long long ll;

int main()
{
	cin.sync_with_stdio(false);
	//freopen("minimal.in", "r", stdin);
	//freopen("minimal.out", "w", stdout);
	int n,t;
	cin >> n >> t;
	char c[100010];
	int index = 0;
	int a[100010] = {};
	for (int i = 0; i < n;++i)
	{
		cin >> c[i];
		if ((i == 0 && c[0] != 'a') || (i > 0 && c[i] != c[i - 1]))
			++index;
		++a[index];
	}
	ui ans = 0;
	for (int i = 0; i <= index; ++i)
	{
		int h = t;
		ui cur = 0;
		int st = 0;
		for (int j = i; j <= index; ++j)
		{
			if (j % 2 == 0)
				cur += a[j];
			else
			{
				cur += min(a[j], h);
				h -= a[j];
				if (h < 0)
					break;
			}
			st += a[j];
		}
		if (st < ans)
			break;
		ans = max(ans, cur);
		h = t;
		cur = 0;
		for (int j = i; j <= index; ++j)
		{
			if (j % 2 != 0)
				cur += a[j];
			else
			{
				cur += min(a[j], h);
				h -= a[j];
				if (h < 0)
					break;
			}
		}
		ans = max(ans, cur);
	}
	cout << ans << endl;
	return 0;
}


#pragma comment(linker, "/STACK:99777216")
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>

#define M_PI 3.14159265358979323846

using namespace std;

typedef unsigned __int64 ui;
typedef __int64 si;
typedef long long ll;

string s;
int n, k;
//map<char, int> f;

int calc(char c)
{
	int len = 0, maxlen = 0;
	int l = 0, r = -1;
	int ch = 0;
	while (r < n - 1)
	{
		++r;
		++len;
		if (s[r] == c)
			++ch;
		while (ch > k)
		{
			if (s[l] == c)
				--ch;
			++l;
			--len;
		}
		maxlen = max(len, maxlen);
	}
	return maxlen;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	cin >> s;

	cout <<  max(calc('a'), calc('b')) << endl;
	return 0;
}


#pragma comment(linker, "/STACK:99777216")
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>

#define M_PI 3.14159265358979323846

using namespace std;

typedef unsigned __int64 ui;
typedef __int64 si;
typedef long long ll;

int main()
{
	cin.sync_with_stdio(false);
	//freopen("minimal.in", "r", stdin);
	//freopen("minimal.out", "w", stdout);
	int n,t;
	cin >> n >> t;
	char c[100010];
	int index = 0;
	int a[100010] = {};
	for (int i = 0; i < n;++i)
	{
		cin >> c[i];
		if ((i == 0 && c[0] != 'a') || (i > 0 && c[i] != c[i - 1]))
			++index;
		++a[index];
	}
	ui ans = 0;
	for (int i = 0; i <= index; ++i)
	{
		int h = t;
		ui cur = 0;
		int st = 0;
		int j;
		for (j = i; j <= index; ++j)
		{
			if (j % 2 == 0)
				cur += a[j];
			else
			{
				cur += min(a[j], h);
				h -= a[j];
				if (h < 0)
					break;
			}
			st += a[j];
		}
		if (st < ans && j >= index)
			break;
		ans = max(ans, cur);
		h = t;
		cur = 0;
		for (j = i; j <= index; ++j)
		{
			if (j % 2 != 0)
				cur += a[j];
			else
			{
				cur += min(a[j], h);
				h -= a[j];
				if (h < 0)
					break;
			}
		}
		ans = max(ans, cur);
	}
	cout << ans << endl;
	return 0;
}


#pragma comment(linker, "/STACK:99777216")
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>

#define M_PI 3.14159265358979323846

using namespace std;

typedef unsigned __int64 ui;
typedef __int64 si;
typedef long long ll;

string s;
int n, k;
//map<char, int> f;

int calc(char c)
{
	int len = 0, maxlen = 0;
	int l = 0, r = -1;
	int ch = 0;
	while (r < n)
	{
		++r;
		++len;
		if (s[r] == c)
			++ch;
		while (ch > k)
		{
			if (s[l] == c)
				--ch;
			++l;
			--len;
		}
		maxlen = max(len, maxlen);
	}
	return maxlen;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	cin >> s;

	cout <<  max(calc('a'), calc('b')) - 1 << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAXN = (int) 1e6 + 10;
const int MOD = (int) 1e9 + 7;
int a[MAXN], b[MAXN];
int aa[MAXN], bb[MAXN];
int n;
int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
	  scanf("%d", &a[i]);
	for (int i=1; i<=n; i++)
	  scanf("%d", &b[i]);
	if (b[0] != a[0] || b[n] != a[n]) {
		puts("No");
		return 0;
	}
	for (int i=2; i<=n; i++) {
		aa[i-1] = a[i] - a[i-1];
		bb[i-1] = b[i] - b[i-1];
	}
	sort(aa+1, aa+n);
	sort(bb+1, bb+n);
	for (int i=1; i<n; i++) {
		if (aa[i] != bb[i]) {
			puts("No");
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAXN = (int) 1e6 + 10;
const int MOD = (int) 1e9 + 7;
int n;
int a[MAXN], b[MAXN];
int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
	  scanf("%d", &a[i]);
	for (int i=1; i<=n; i++)
	  scanf("%d", &b[i]);
	for (int i=2; i<n; i++) {
		b[i] = b[i-1] + b[i+1] - b[i];
	}
	bool judge = 0;
	for (int i=1; i<=n; i++) {
		if (a[i] != b[i]) judge = 1;
	}
	if (judge) cout << "No" << endl;
else 	cout << "Yes" << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAXN = (int) 1e6 + 10;
const int MOD = (int) 1e9 + 7;
int n;
int a[MAXN], b[MAXN];
int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
	  scanf("%d", &a[i]);
	for (int i=1; i<=n; i++)
	  scanf("%d", &b[i]);
	int l = 2, r = n - 1;
	while (l <= r) {
		if (a[l-1] + a[l+1] - a[l] == b[l]) {
			a[l] = a[l-1] + a[l+1] - a[l];
			l ++;
		} else if (a[r-1] + a[r+1] - a[r] == b[r]) {
			a[r] = a[r-1] + a[r+1] - a[r];
			r --;
		} else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define fastcin() ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef pair<int, int> ii;

const int maxn = 2e5;
int a[maxn], b[maxn], n;
signed main()
{
	cin >> n; int x, y;
	for(int i = 0, pre, tmp; i < n; i++) {
		cin >> tmp;
		if(i) a[i] = tmp - pre;
		else x = tmp; pre = tmp;
	}
	for(int i = 0, pre, tmp; i < n; i++) {
		cin >> tmp;
		if(i) b[i] = tmp - pre;
		else y = tmp; pre = tmp;
	}
	sort(a+1, a+n);
	sort(b+1, b+n);
	if(x != y) {
		cout << "No";
		return 0;
	}
	for(int i = 1; i < n; i++)
		if(a[i] != b[i]) {
			cout << "No";
			return 0;
		}
	cout << "Yes";
}


#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define fastcin() ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef pair<int, int> ii;

const int maxn = 2e5;
int a[maxn], b[maxn], n;
signed main()
{
	cin >> n;
	if(n == 1) {
		int p, q; cin >> p >> q; if(p == q) cout << "Yes"; else cout << "No";
		return 0;
	}
	for(int i = 0, pre, tmp; i < n; i++) {
		cin >> tmp;
		if(i) a[i] = tmp - pre; pre = tmp;
	}
	for(int i = 0, pre, tmp; i < n; i++) {
		cin >> tmp;
		if(i) b[i] = tmp - pre; pre = tmp;
	}
	sort(a+1, a+n);
	sort(b+1, b+n);
	for(int i = 1; i < n; i++)
		if(a[i] != b[i]) {
			cout << "No";
			return 0;
		}
	cout << "Yes";
}


#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define fastcin() ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef pair<int, int> ii;

const int maxn = 2e5;
int a[maxn], b[maxn], n;
signed main()
{
	cin >> n;
	for(int i = 0, pre, tmp; i < n; i++) {
		cin >> tmp;
		if(i) a[i] = tmp - pre; pre = tmp;
	}
	for(int i = 0, pre, tmp; i < n; i++) {
		cin >> tmp;
		if(i) b[i] = tmp - pre; pre = tmp;
	}
	sort(a+1, a+n);
	sort(b+1, b+n);
	for(int i = 1; i < n; i++)
		if(a[i] != b[i]) {
			cout << "No";
			return 0;
		}
	cout << "Yes";
}


#include <bits/stdc++.h>
using namespace std;
const int N=100005;
#define ll long long
inline ll read(){
	ll x=0;char ch=getchar();bool f=0;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return f?-x:x;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);putchar(x%10+'0');
}
int n,a[N],b[N],c[N];
int main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) b[i]=a[i]-a[i-1];
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) c[i]=a[i]-a[i-1];
	sort(b+1,b+n+1);sort(c+1,c+n+1);
	for(int i=1;i<=n;i++) if(b[i]!=c[i]) return puts("No"),0;
	puts("Yes");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=100005;
#define ll long long
inline ll read(){
	ll x=0;char ch=getchar();bool f=0;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return f?-x:x;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);putchar(x%10+'0');
}
int n,a[N],b[N],c[N];
int main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) b[i]=a[i]-a[i-1];
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) c[i]=a[i]-a[i-1];
	if(b[1]!=c[1]) return puts("No"),0;
	sort(b+1,b+n+1);sort(c+1,c+n+1);
	for(int i=1;i<=n;i++) if(b[i]!=c[i]) return puts("No"),0;
	puts("Yes");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=100005;
#define ll long long
inline ll read(){
	ll x=0;char ch=getchar();bool f=0;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return f?-x:x;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);putchar(x%10+'0');
}
int n,a[N],b[N],c[N];
int main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=2;i<n;i++) b[i]=a[i]-a[i-1];
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=2;i<n;i++) c[i]=a[i]-a[i-1];
	sort(b+1,b+n+1);sort(c+1,c+n+1);
	for(int i=1;i<=n;i++) if(b[i]!=c[i]) return puts("No"),0;
	puts("Yes");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=10005;
#define ll long long
inline ll read(){
	ll x=0;char ch=getchar();bool f=0;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return f?-x:x;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);putchar(x%10+'0');
}
int n,a[N],b[N],c[N];
int main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) b[i]=a[i]-a[i-1];
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) c[i]=a[i]-a[i-1];
	sort(b+1,b+n+1);sort(c+1,c+n+1);
	for(int i=1;i<=n;i++) if(b[i]!=c[i]) return puts("No"),0;
	puts("Yes");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=100005;
#define ll long long
inline ll read(){
	ll x=0;char ch=getchar();bool f=0;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return f?-x:x;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);putchar(x%10+'0');
}
int n,a[N],b[N],c[N];
int main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) b[i]=a[i]-a[i-1];
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) c[i]=a[i]-a[i-1];
	if(b[1]!=c[1]||b[n]!=c[n]) return puts("No"),0;
	sort(b+1,b+n+1);sort(c+1,c+n+1);
	for(int i=1;i<=n;i++) if(b[i]!=c[i]) return puts("No"),0;
	puts("Yes");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=100005;
#define ll long long
inline ll read(){
	ll x=0;char ch=getchar();bool f=0;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return f?-x:x;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);putchar(x%10+'0');
}
int n,a[N],b[N],c[N];
int main(){
	n=read();
	if(n==2){
		for(int i=1;i<=n;i++) a[i]=read();
		for(int i=1;i<=n;i++) b[i]=read();
		for(int i=1;i<=n;i++) if(b[i]!=c[i]) return puts("No"),0;
		puts("Yes");
		return 0;
	}
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) b[i]=a[i]-a[i-1];
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) c[i]=a[i]-a[i-1];
	sort(b+1,b+n+1);sort(c+1,c+n+1);
	for(int i=1;i<=n;i++) if(b[i]!=c[i]) return puts("No"),0;
	puts("Yes");
	return 0;
}


#include <bits/stdc++.h>
using namespace std ;

int n ;

int x = 0 ;

int main()
{
cin >> n ;
int c[n] , t[n] , a[n] , b[n] ;
for( int i = 0 ; i < n ; i ++){
	cin >> c[i] ;
}
for( int i = 0 ; i < n ; i ++){
	cin >> t[i] ;
}
if(c[0] == t[0] && c[n-1] == t[n-1]){
for( int i = 0 ; i < n-1 ; i ++){
  a[i] = c[i+1] - c [i] ;
  b[i] = t[i+1] - t[i] ;
}
sort (a , a + n-1) ;
sort (b , b + n-1) ;
for(int i =  0 ; i < n-1 ; i++){
	if(a[i] != b[i] ){
		x = 1 ;
		break ;
	}
}
if(x == 1){
	cout << "No" ;
}
else{
	cout << "Yes" ;
}
}
else{
	cout << "No" ;
}
	return 0;
}


#include<iostream>
using namespace std ;
int main()
{
int n ;
int x = 0 ;
cin >> n ;
int c[n] , t[n] , a[n-1] , b[n-1] ;
for(int i =0 ; i < n ; i ++){
  cin >> c[i] ;
}
for(int i =0 ; i < n ; i ++){
  cin >> t[i] ;
}
for(int i =0 ; i < n-1 ; i ++){
  a[i] = c[i+1] - c[i] ;
  b[i] = t[i+1] - t[i] ;
}
for(int i =0 ; i < n ; i ++){
  for(int j = 0 ; i< n ; j++){
		if(a[i] > a[j]){
			int t = a[i] ;
	       a[i] = a[j] ;
			a[j] = t ;
		}
		if(b[i] > b[j]){
			int t = b[i] ;
	       b[i] = b[j] ;
			b[j] = t ;
		}
	}
	if(a[i] !=  b[i]){
	  x = 1 ;
	}
}
if(x == 1)
	cout << "No" ;
else
	cout << "Yes" ;

return 0 ;
}


#include<iostream>
using namespace std ;
int main()
{
int n ;
int x = 0 ;
cin >> n ;
long int c[n] , t[n] , a[n-1] , b[n-1] ;
for(int i =0 ; i < n ; i ++){
  cin >> c[i] ;
}
for(int i =0 ; i < n ; i ++){
  cin >> t[i] ;
}
for(int i =0 ; i < n-1 ; i ++){
  a[i] = c[i+1] - c[i] ;
  b[i] = t[i+1] - t[i] ;
}
sort( a , a+(n-1)) ;
sort(b , b + (n-1)) ;
for(int i = 0 ; i < n-1 ; i++){
 if(a[i] != b[i] ){
	x = 1 ;
	break ;
 }
}
if(x == 1){
	cout << "No" ;
}
else{
	cout << "Yes" ;
}

return 0 ;
}


#include<bits/stdc++>
using namespace std ;
int main()
{
int n ;
int x = 0 ;
cin >> n ;
long int c[n] , t[n] , a[n-1] , b[n-1] ;
for(int i =0 ; i < n ; i ++){
  cin >> c[i] ;
}
for(int i =0 ; i < n ; i ++){
  cin >> t[i] ;
}
for(int i =0 ; i < n-1 ; i ++){
  a[i] = c[i+1] - c[i] ;
  b[i] = t[i+1] - t[i] ;
}
sort( a , a+(n-1)) ;
sort(b , b + (n-1)) ;
for(int i = 0 ; i < n-1 ; i++){
 if(a[i] != b[i] ){
	x = 1 ;
	break ;
 }
}
if(x == 1){
	cout << "No" ;
}
else{
	cout << "Yes" ;
}

return 0 ;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;

const int INF = 0x3ffffff;
const int MOD = 1e9 + 7;
const ll HASH_KEY = 6151;
const ll HASH_MOD = 1610612741;

// mt19937 rdm(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int n;
  cin >> n;
  int c[n], t[n];

  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  for (int i = n - 1; i > 0; i--) {
    c[i] -= c[i - 1];
    t[i] -= t[i - 1];
  }
  sort(c + 1, c + n);
  sort(t + 1, t + n);
  for (int i = 1; i < n; i++) {
    if (c[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;

const int INF = 0x3ffffff;
const int MOD = 1e9 + 7;
const ll HASH_KEY = 6151;
const ll HASH_MOD = 1610612741;

// mt19937 rdm(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int n;
  cin >> n;
  int c[n], t[n];

  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  if (c[0] != t[0] || c[n - 1] != t[n - 1]) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = n - 1; i > 0; i--) {
    c[i] -= c[i - 1];
    t[i] -= t[i - 1];
  }
  sort(c, c + n);
  sort(t, t + n);
  for (int i = 0; i < n; i++) {
    if (c[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;

const int INF = 0x3ffffff;
const int MOD = 1e9 + 7;
const ll HASH_KEY = 6151;
const ll HASH_MOD = 1610612741;

// mt19937 rdm(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int n;
  cin >> n;
  int c[n], t[n];

  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  for (int i = n - 1; i > 0; i--) {
    c[i] -= c[i - 1];
    t[i] -= t[i - 1];
  }
  sort(c, c + n);
  sort(t, t + n);
  for (int i = 1; i < n; i++) {
    if (c[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=1e5+5;
int n,a[MN],b[MN],sa[MN],sb[MN];
int main(){
	scanf("%d",&n);
	for(reg int i=1;i<=n;i++)scanf("%d",a+i);
	for(reg int i=1;i<=n;i++)scanf("%d",b+i);
	for(reg int i=1;i<=n;i++)sa[i]=a[i]-a[i-1];
	for(reg int i=1;i<=n;i++)sb[i]=b[i]-b[i-1];
	sort(sa+1,sa+1+n);sort(sb+1,sb+1+n);
	for(reg int i=1;i<=n;i++)
		if(sa[i]!=sb[i])return 0*puts("No");
	puts("Yes");
	return 0;
}


#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=1e5+5;
int n,a[MN],b[MN],c[MN];
int main(){
	scanf("%d",&n);
	for(reg int i=1;i<=n;i++)scanf("%d",a+i);
	for(reg int i=1;i<=n;i++)scanf("%d",b+i);
	for(reg int i=n;i;i--)a[i]-=a[i-1],b[i]-=b[i-1];
	if(a[1]!=b[1])return 0*puts("No");
	sort(a+2,a+1+n);sort(b+2,b+1+n);
	for(reg int i=2;i<=n;i++)
		if(a[i]!=b[i])return 0*puts("No");
	puts("Yes");
	return 0;
}


#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=1e5+5;
int n,a[MN],b[MN],sa[MN],sb[MN];
int main(){
	scanf("%d",&n);
	for(reg int i=1;i<=n;i++)scanf("%d",a+i);
	for(reg int i=1;i<=n;i++)scanf("%d",b+i);
	if(a[1]!=b[1])return 0*puts("No");
	for(reg int i=1;i<=n;i++)sa[i]=a[i]-a[i-1];
	for(reg int i=1;i<=n;i++)sb[i]=b[i]-b[i-1];
	sort(sa+1,sa+1+n);sort(sb+1,sb+1+n);
	for(reg int i=1;i<=n;i++)
		if(sa[i]!=sb[i])return 0*puts("No");
	puts("Yes");
	return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define MAXN 100005
#define INF (1<<25)
#define P int(1e9+7)
using namespace std;

int N;
int c[MAXN], t[MAXN];

int main(){
	//freopen("1.in", "r", stdin);
	ios::sync_with_stdio(0);
	cin>>N;

	for(int i=1;i<=N;i++) cin>>c[i];
	for(int i=1;i<=N;i++) cin>>t[i];

	if(c[1]!=t[1] || c[N]!=t[N]){
		cout<<"No";
		return 0;
	}

	bool ok = 1;
	for(int i=2;i<=N-1;i++){
		if(t[i]!=c[i]){
			if(c[i] != t[i-1] + t[i+1] - t[i]){
				ok = 0;
				//cout<<i<<endl;
				break;
			}
			else{
				t[i] = c[i];
			}
		}
	}
	if(ok) cout<<"Yes";
	else{
		ok = 1;
		for(int i=N-1;i>=2;i--){
			if(t[i]!=c[i]){
				if(c[i] != t[i-1] + t[i+1] - t[i]){
					ok = 0;
					//cout<<i<<endl;
					break;
				}
				else{
					t[i] = c[i];
				}
			}
		}
		if(ok) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define MAXN 100005
#define INF (1<<25)
#define P int(1e9+7)
using namespace std;

int N;
int c[MAXN], t[MAXN];

int main(){
	//freopen("1.in", "r", stdin);
	ios::sync_with_stdio(0);
	cin>>N;

	for(int i=1;i<=N;i++) cin>>c[i];
	for(int i=1;i<=N;i++) cin>>t[i];

	if(c[1]!=t[1] || c[N]!=t[N]){
		cout<<"No";
		return 0;
	}

	bool ok = 1;
	for(int i=2;i<=N-1;i++){
		if(t[i]!=c[i]){
			if(c[i] != t[i-1] + t[i+1] - t[i]){
				ok = 0;
				//cout<<i<<endl;
				break;
			}
			else{
				t[i] = c[i];
			}
		}
	}
	if(ok) cout<<"Yes";
	else cout<<"No";
	return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define MAXN 100005
#define INF (1<<25)
#define P int(1e9+7)
using namespace std;

int N;
int c[MAXN], t[MAXN];

int main(){
	//freopen("1.in", "r", stdin);
	ios::sync_with_stdio(0);
	cin>>N;

	for(int i=1;i<=N;i++) cin>>c[i];
	for(int i=1;i<=N;i++) cin>>t[i];

	if(c[1]!=t[1] || c[N]!=t[N]){
		cout<<"No";
		return 0;
	}

	for(int i=1;i<N;i++){
		c[i] = c[i+1] - c[i];
		t[i] = t[i+1] - t[i];
	}
	sort(c+1,c+N);
	sort(t+1,t+N);

	bool ok = 1;
	for(int i=1;i<N;i++){
		//cout<<c[i]<<" "<<t[i]<<endl;
		if(c[i]!=t[i]){
			ok = 0;
			break;
		}
	}

	if(ok) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define MAXN 100005
#define INF (1<<25)
#define P int(1e9+7)
using namespace std;

int N;
int c[MAXN], t[MAXN];

int main(){
	//freopen("1.in", "r", stdin);
	ios::sync_with_stdio(0);
	cin>>N;

	for(int i=1;i<=N;i++) cin>>c[i];
	for(int i=1;i<=N;i++) cin>>t[i];

	if(c[1]!=t[1] || c[N]!=t[N]){
		cout<<"No";
		return 0;
	}

	bool ok = 1;
	for(int i=2;i<=N-1;i++){
		if(t[i]!=c[i]){
			if(c[i] != t[i-1] + t[i+1] - t[i]){
				ok = 0;
				cout<<i<<endl;
				break;
			}
			else{
				t[i] = c[i];
			}
		}
	}
	if(ok) cout<<"Yes";
	else cout<<"No";
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N = 1e5;
int a[N+3];
int b[N+3];
int da[N+3];
int db[N+3];
int n;

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]),da[i] = da[i]-a[i-1];
	for(int i=1; i<=n; i++) scanf("%d",&b[i]),db[i] = db[i]-b[i-1];
	sort(da+2,da+n+1); sort(db+2,db+n+1);
	for(int i=1; i<=n; i++)
	{
		if(da[i]!=db[i]) {puts("No"); return 0;}
	}
	puts("Yes"); return 0;
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N = 1e5;
int a[N+3];
int b[N+3];
int da[N+3];
int db[N+3];
int n;

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]),da[i] = da[i]-da[i-1];
	for(int i=1; i<=n; i++) scanf("%d",&b[i]),db[i] = db[i]-db[i-1];
	if(a[1]!=b[1]) {puts("No"); return 0;}
	sort(da+2,da+n+1); sort(db+2,db+n+1);
	for(int i=2; i<=n; i++)
	{
		if(da[i]!=db[i]) {puts("No"); return 0;}
	}
	puts("Yes"); return 0;
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

const int N = 1e5;
int a[N+3];
int b[N+3];
int n;

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]),da[i] = da[i]-da[i-1];
	for(int i=1; i<=n; i++) scanf("%d",&b[i]),db[i] = db[i]-db[i-1];
	if(a[1]!=b[1]) {puts("No"); return 0;}
	sort(da+2,da+n+1); sort(db+2,db+n+1);
	for(int i=2; i<=n; i++)
	{
		if(da[i]!=db[i]) {puts("No"); return 0;}
	}
	puts("Yes"); return 0;
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N = 1e5;
int a[N+3];
int b[N+3];
int da[N+3];
int db[N+3];
int n;

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]),da[i] = a[i]-a[i-1];
	for(int i=1; i<=n; i++) scanf("%d",&b[i]),db[i] = b[i]-b[i-1];
	sort(da+2,da+n+1); sort(db+2,db+n+1);
	for(int i=1; i<=n; i++)
	{
		if(da[i]!=db[i]) {puts("No"); return 0;}
	}
	puts("Yes"); return 0;
	return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

const int N=1e6+5;

int n,m,a[N],b[N],da[N],db[N],ans;

signed main()
{
	n=read();
	for ( int i=1;i<=n;i++ ) a[i]=read();
	for ( int i=1;i<=n;i++ ) b[i]=read();
	if(a[1]!=b[1]||a[n]!=b[n])
		return printf("No\n"),0;
	for ( int i=1;i<n;i++ )
		da[i]=a[i+1]-a[i],db[i]=b[i+1]-b[i];
	sort(da+1,da+n);
	sort(db+1,db+n);
	for ( int i=1;i<n;i++ )
		if(da[i]!=db[i])
			return printf("No\n"),0;
	printf("Yes\n");
	return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

const int N=1e6+5;

int n,m,a[N],b[N],da[N],db[N],ans;

signed main()
{
	n=read();
	for ( int i=1;i<=n;i++ ) a[i]=read();
	for ( int i=1;i<=n;i++ ) b[i]=read();
	a[0]=-100;
	a[n+1]=-100;
	for ( int i=1;i<=n+1;i++ )
		da[i]=a[i]-a[i-1],db[i]=b[i]-b[i-1];
	sort(da+1,da+n+2);
	sort(db+1,db+n+2);
	for ( int i=1;i<=n+1;i++ )
		if(da[i]!=db[i])
			return printf("No\n"),0;
	printf("Yes\n");
	return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

const int N=1e6+5;

int n,m,a[N],b[N],da[N],db[N],ans;

signed main()
{
	n=read();
	for ( int i=1;i<=n;i++ ) a[i]=read();
	for ( int i=1;i<=n;i++ ) b[i]=read();
	for ( int i=1;i<n;i++ )
		da[i]=a[i+1]-a[i],db[i]=b[i+1]-b[i];
	sort(da+1,da+n);
	sort(db+1,db+n);
	for ( int i=1;i<n;i++ )
		if(da[i]!=db[i])
			return printf("No\n"),0;
	printf("Yes\n");
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;
#define rep(i, j, k) for (int i = int(j); i <= int(k); ++ i)
#define dwn(i, j, k) for (int i = int(j); i >= int(k); -- i)
typedef long long LL;
typedef pair<int, int> P;
const int N = 1e5 + 7;
LL c[N], t[N], n, a[N], b[N];

int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	rep(i, 1, n) cin >> c[i];
	rep(i, 1, n) cin >> t[i];
	LL c1 = 2e9 + 7;
	LL c2 = 2e9 + 7;
	rep(i, 1, n) c1 = min(c1, c[i]);
	rep(i, 1, n) c2 = min(c2, t[i]);
	if (c1 != c2) {
		cout << "No" << endl;return 0;
	}
	rep(i, 1, n - 1) a[i] = c[i + 1] - c[i];
	rep(i, 1, n - 1) b[i] = t[i + 1] - t[i];
	sort(a + 1, a + n);
	sort(b + 1, b + n);
	rep(i, 1, n - 1)
	if (a[i] != b[i]) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;
#define rep(i, j, k) for (int i = int(j); i <= int(k); ++ i)
#define dwn(i, j, k) for (int i = int(j); i >= int(k); -- i)
typedef long long LL;
typedef pair<int, int> P;
const int N = 1e5 + 7;
LL c[N], t[N], n, a[N], b[N];

int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	rep(i, 1, n) cin >> c[i];
	rep(i, 1, n) cin >> t[i];
	rep(i, 1, n - 1) a[i] = c[i + 1] - c[i];
	rep(i, 1, n - 1) b[i] = t[i + 1] - t[i];
	sort(a + 1, a + n);
	sort(b + 1, b + n);
	rep(i, 1, n - 1)
	if (a[i] != b[i]) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;
#define rep(i, j, k) for (int i = int(j); i <= int(k); ++ i)
#define dwn(i, j, k) for (int i = int(j); i >= int(k); -- i)
typedef long long LL;
typedef pair<int, int> P;
const int N = 1e5 + 7;
int c[N], t[N], n, a[N], b[N];

int main() {
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d", c + i);
	rep(i, 1, n) scanf("%d", t + i);
	rep(i, 1, n - 1) a[i] = c[i + 1] - c[i];
	rep(i, 1, n - 1) b[i] = t[i + 1] - t[i];
	sort(a + 1, a + n);
	sort(b + 1, b + n);
	rep(i, 1, n - 1)
	if (a[i] != b[i]) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;
#define rep(i, j, k) for (int i = int(j); i <= int(k); ++ i)
#define dwn(i, j, k) for (int i = int(j); i >= int(k); -- i)
typedef long long LL;
typedef pair<int, int> P;
const int N = 1e5 + 7;
LL c[N], t[N], n, a[N], b[N];

int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	rep(i, 1, n) cin >> c[i];
	rep(i, 1, n) cin >> t[i];
	int c1 = 2e9 + 7;
	int c2 = 2e9 + 7;
	rep(i, 1, n) c1 = min(c1, c[i]);
	rep(i, 1, n) c2 = min(c2, t[i]);
	if (c1 != c2) {
		cout << "No" << endl;return 0;
	}
	rep(i, 1, n - 1) a[i] = c[i + 1] - c[i];
	rep(i, 1, n - 1) b[i] = t[i + 1] - t[i];
	sort(a + 1, a + n);
	sort(b + 1, b + n);
	rep(i, 1, n - 1)
	if (a[i] != b[i]) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;
#define rep(i, j, k) for (int i = int(j); i <= int(k); ++ i)
#define dwn(i, j, k) for (int i = int(j); i >= int(k); -- i)
typedef long long LL;
typedef pair<int, int> P;
const int N = 1e5 + 7;
LL c[N], t[N], n, a[N], b[N];

int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	rep(i, 1, n) cin >> c[i];
	rep(i, 1, n) cin >> t[i];
	if (c[1] != t[1] || c[n] != t[n]) {
		cout << "No";
		return 0;
	}
	rep(i, 1, n - 1) a[i] = c[i + 1] - c[i];
	rep(i, 1, n - 1) b[i] = t[i + 1] - t[i];
	sort(a + 1, a + n);
	sort(b + 1, b + n);
	rep(i, 1, n - 1)
	if (a[i] != b[i]) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}


//TEMPLATE DO RENATO SINCE 1929
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int,int>;
#define ff first
#define ss second
#define pb push_back
#define ins insert
#define eb emplace_back
using vi = vector<int>;
const int N = 2e5+10;

int n;ll x;
ll dif1[N],dif2[N];

int main(){
	scanf("%d",&n);
	ll a,b,c,d;
	ll an;
	for(int i=0;i<n;i++){
		scanf("%lld",&x);
		if(i>0)dif1[i-1]=an-x;
		else a=x;
		an=x;
		if(i==n-1)b=x;
	}
	for(int i=0;i<n;i++){
		scanf("%lld",&x);
		if(i>0)dif2[i-1]=an-x;
		else c=x;
		an=x;
		if(i==n-1)d=x;
	}

	//for(int i=0;i<n-1;i++)cout<<dif1[i]<<' ';cout<<endl;
	//for(int i=0;i<n-1;i++)cout<<dif2[i]<<' ';cout<<endl;

	bool val=0;

	if(c==a and b==d){
		for(int i=0;i<n-1;i++){
			if(dif1[0]==dif2[i]){
				//cout<<"MATCH ON "<<i<<", TESTING\n";
				bool t=1;
				for(int j=0;j<n-1;j++){
					//cout<<"TEST dif1["<<j<<"]="<<dif1[j]<<" dif2["<<(j+i)%(n-1)<<"]="<<dif2[(j+i)%(n-1)]<<endl;
					if(dif1[j]!=dif2[(j+i)%(n-1)]){t=0;break;}
				}
				if(t)val=1;
			}
		if(val)break;
		}
	}

	if(val)printf("Yes\n");
	else printf("No\n");
	return 0;
}


//TEMPLATE DO RENATO SINCE 1929
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int,int>;
#define ff first
#define ss second
#define pb push_back
#define ins insert
#define eb emplace_back
using vi = vector<int>;
const int N = 1e5+10;

int n,x;
int dif1[N],dif2[N];

int main(){
	scanf("%d",&n);
	int a,b,c,d;
	int an;
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		if(i>0)dif1[i-1]=x-an;
		else a=x;
		an=x;
		if(i==n-1)b=x;
	}
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		if(i>0)dif2[i-1]=x-an;
		else c=x;
		an=x;
		if(i==n-1)d=x;
	}

	//for(int i=0;i<n-1;i++)cout<<dif1[i]<<' ';cout<<endl;
	//for(int i=0;i<n-1;i++)cout<<dif2[i]<<' ';cout<<endl;

	bool val=0;

	if(c==a and b==d){
		for(int i=0;i<n-1;i++){
			if(dif1[0]==dif2[i]){
				bool t=1;
				for(int j=0;j<n-1;j++){
					if(dif1[j]!=dif2[(j+i)%(n-1)]){t=0;break;}
				}
				if(t)val=1;
			}
		if(val)break;
		}
	}

	if(val)printf("Yes\n");
	else printf("No\n");
	return 0;
}


//TEMPLATE DO RENATO SINCE 1929
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int,int>;
#define ff first
#define ss second
#define pb push_back
#define ins insert
#define eb emplace_back
using vi = vector<int>;
const int N = 2e5+10;

int n;ll x;
ll dif1[N],dif2[N];

int main(){
	scanf("%d",&n);
	ll a,b,c,d;
	ll an;
	for(int i=0;i<n;i++){
		scanf("%lld",&x);
		if(i>0)dif1[i-1]=an-x;
		else a=x;
		an=x;
		if(i==n-1)b=x;
	}
	for(int i=0;i<n;i++){
		scanf("%lld",&x);
		if(i>0)dif2[i-1]=an-x;
		else c=x;
		an=x;
		if(i==n-1)d=x;
	}

	//for(int i=0;i<n-1;i++)cout<<dif1[i]<<' ';cout<<endl;
	//for(int i=0;i<n-1;i++)cout<<dif2[i]<<' ';cout<<endl;

	bool val=0;

	if(c==a and b==d){
		sort(dif1,dif1+n-1);
		sort(dif2,dif2+n-1);
		bool f=0;
		for(int i=0;i<n-1;i++)if(dif1[i]!=dif2[i])f=1;
		if(!f)val=1;
	}

	if(val)printf("Yes\n");
	else printf("No\n");
	return 0;
}


//TEMPLATE DO RENATO SINCE 1929
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int,int>;
#define ff first
#define ss second
#define pb push_back
#define ins insert
#define eb emplace_back
using vi = vector<int>;
const int N = 2e5+10;

int n;ll x;
ll dif1[N],dif2[N];

int main(){
	scanf("%d",&n);
	ll a,b,c,d;
	ll an;
	for(int i=0;i<n;i++){
		scanf("%lld",&x);
		if(i>0)dif1[i-1]=an-x;
		else a=x;
		an=x;
		if(i==n-1)b=x;
	}
	for(int i=0;i<n;i++){
		scanf("%lld",&x);
		if(i>0)dif2[i-1]=an-x;
		else c=x;
		an=x;
		if(i==n-1)d=x;
	}

	//for(int i=0;i<n-1;i++)cout<<dif1[i]<<' ';cout<<endl;
	//for(int i=0;i<n-1;i++)cout<<dif2[i]<<' ';cout<<endl;

	bool val=0;

	set<ll> aux;

	if(c==a and b==d){
		for(int i=0;i<n-1;i++)aux.insert(dif1[i]),aux.insert(dif2[i]);
	}

	if(aux.size()==n-1)val=1;

	if(val)printf("Yes\n");
	else printf("No\n");
	return 0;
}


#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i )
#define sz(x) ((int) x.size())
#define all(x) x.begin(),x.end()
#define asd cout<<"ok"<<endl;
#define endl '\n'

const int maxn = 100005;
ll a[maxn], b[maxn];
void f(ll *a, ll x) {
    if(x==1) return;
    if(a[x+1]+a[x-1]<2*a[x]) a[x]=a[x+1]+a[x-1]-a[x],f(a,x-1);
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    ii cin>>a[i];
    ii cin>>b[i];
    if(a[1]!=b[1] || a[n]!=b[n]) return cout<<"No"<<endl,0;
    for(ll i=2;i<=n-1;++i) f(a,i),f(b,i);
    ii if(a[i]!=b[i]) return cout<<"No"<<endl,0;
    cout<<"Yes"<<endl;
}


#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i )
#define sz(x) ((int) x.size())
#define all(x) x.begin(),x.end()
#define asd cout<<"ok"<<endl;
#define endl '\n'

const int maxn = 100005;
ll a[maxn], b[maxn];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    ii cin>>a[i];
    ii cin>>b[i];
    if(a[1]!=b[1] || a[n]!=b[n]) return cout<<"No"<<endl,0;
    vector<ll> v1,v2;
    for(int i=1;i<=n-1;++i) v1.push_back(a[i]-a[i+1]),v2.push_back(b[i]-b[i+1]);
    sort(all(v1));sort(all(v2));
    if(v1!=v2) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i )
#define sz(x) ((int) x.size())
#define all(x) x.begin(),x.end()
#define asd cout<<"ok"<<endl;
#define endl '\n'

const int maxn = 100005;
int a[maxn], b[maxn];
void f(int *a, int x) {
    if(x==1) return;
    if(a[x+1]+a[x-1]<2*a[x]) a[x]=a[x+1]+a[x-1]-a[x],f(a,x-1);
}
int main()
{
    int n;
    cin>>n;
    ii cin>>a[i];
    ii cin>>b[i];
    if(a[1]!=b[1] || a[n]!=b[n]) return cout<<"No"<<endl,0;
    for(int i=2;i<=n-1;++i) f(a,i),f(b,i);
    ii if(a[i]!=b[i]) return cout<<"No"<<endl,0;
    cout<<"Yes"<<endl;
}


#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i )
#define sz(x) ((int) x.size())
#define all(x) x.begin(),x.end()
#define asd cout<<"ok"<<endl;
#define endl '\n'

const int maxn = 100005;
ll a[maxn], b[maxn];
void f(ll *a, ll x) {
    if(x==1) return;
    if(a[x+1]+a[x-1]<2*a[x]) a[x]=a[x+1]+a[x-1]-a[x],f(a,x-1);
}
int main()
{
    int n;
    cin>>n;
    ii cin>>a[i];
    ii cin>>b[i];
    if(a[1]!=b[1] || a[n]!=b[n]) return cout<<"No"<<endl,0;
    for(ll i=2;i<=n-1;++i) f(a,i),f(b,i);
    ii if(a[i]!=b[i]) return cout<<"No"<<endl,0;
    cout<<"Yes"<<endl;
}


#include <bits/stdc++.h>
#define jh(x,y) x^=y^=x^=y
#define lowbit(x) (x&-x)
#define rg register
#define inl inline
typedef long long ll;
const int N = 1e5 + 5, mod = 1e9 + 7;
using namespace std;
namespace fast_IO {
	inl ll read()
	{
		rg ll num = 0;
		rg char ch;
		rg bool flag = false;
		while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
		if (ch == EOF)return ch; if (ch == '-')flag = true; else num = ch ^ 48;
		while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
			num = (num << 1) + (num << 3) + (ch ^ 48);
		if (flag)return -num; return num;
	}
	inl int chread(rg char s[])
	{
		rg int len = 0;
		rg char ch;
		while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
		s[len++] = ch;
		while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
			s[len++] = ch;
		s[len] = 0;
		return len;
	}
	inl ll max(rg ll a, rg ll b) { if (a > b)return a; return b; }
	inl ll min(rg ll a, rg ll b) { if (a < b)return a; return b; }
	void write(rg long long x) { if (x < 0)putchar('-'), x = -x; if (x >= 10)write(x / 10); putchar(x % 10 ^ 48); }
};
ll a[N], b[N];
map<ll, int>mp;

int main(void)
{
	rg int n = fast_IO::read();
	for (rg int i = 1; i <= n; ++i)a[i] = fast_IO::read();
	for (rg int i = 1; i <= n; ++i)b[i] = fast_IO::read();
	if (a[1] != b[1] || a[n] != b[n]) { puts("No"); return 0; }
	for (rg int i = 1; i != n; ++i)++mp[b[i + 1] - b[i]];
	for (rg int i = 1; i != n; ++i)if (!mp[a[i + 1] - a[i]]--) { puts("No"); return 0; }
	puts("Yes");
	return 0;
}


#include <bits/stdc++.h>
#define jh(x,y) x^=y^=x^=y
#define lowbit(x) (x&-x)
#define rg register
#define inl inline
typedef long long ll;
const int N = 1e5 + 5, mod = 1e9 + 7;
using namespace std;
namespace fast_IO {
	inl ll read()
	{
		rg ll num = 0;
		rg char ch;
		rg bool flag = false;
		while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
		if (ch == EOF)return ch; if (ch == '-')flag = true; else num = ch ^ 48;
		while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
			num = (num << 1) + (num << 3) + (ch ^ 48);
		if (flag)return -num; return num;
	}
	inl int chread(rg char s[])
	{
		rg int len = 0;
		rg char ch;
		while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
		s[len++] = ch;
		while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
			s[len++] = ch;
		s[len] = 0;
		return len;
	}
	inl ll max(rg ll a, rg ll b) { if (a > b)return a; return b; }
	inl ll min(rg ll a, rg ll b) { if (a < b)return a; return b; }
	void write(rg long long x) { if (x < 0)putchar('-'), x = -x; if (x >= 10)write(x / 10); putchar(x % 10 ^ 48); }
};
int a[N], b[N];
map<int, int>mp;

int main(void)
{
	rg int n = fast_IO::read();
	for (rg int i = 1; i <= n; ++i)a[i] = fast_IO::read();
	for (rg int i = 1; i <= n; ++i)b[i] = fast_IO::read();
	for (rg int i = 1; i != n; ++i)++mp[b[i + 1] - b[i]];
	for (rg int i = 1; i != n; ++i)if (!mp[a[i + 1] - a[i]]--) { puts("No"); return 0; }
	puts("Yes");
	return 0;
}


#include <bits/stdc++.h>
#define jh(x,y) x^=y^=x^=y
#define lowbit(x) (x&-x)
#define rg register
#define inl inline
typedef long long ll;
const int N = 1e5 + 5, mod = 1e9 + 7;
using namespace std;
namespace fast_IO {
	inl ll read()
	{
		rg ll num = 0;
		rg char ch;
		rg bool flag = false;
		while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
		if (ch == EOF)return ch; if (ch == '-')flag = true; else num = ch ^ 48;
		while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
			num = (num << 1) + (num << 3) + (ch ^ 48);
		if (flag)return -num; return num;
	}
	inl int chread(rg char s[])
	{
		rg int len = 0;
		rg char ch;
		while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
		s[len++] = ch;
		while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
			s[len++] = ch;
		s[len] = 0;
		return len;
	}
	inl ll max(rg ll a, rg ll b) { if (a > b)return a; return b; }
	inl ll min(rg ll a, rg ll b) { if (a < b)return a; return b; }
	void write(rg long long x) { if (x < 0)putchar('-'), x = -x; if (x >= 10)write(x / 10); putchar(x % 10 ^ 48); }
};
int a[N], b[N];
map<int, int>mp;

int main(void)
{
	rg int n = fast_IO::read();
	for (rg int i = 1; i <= n; ++i)a[i] = fast_IO::read();
	for (rg int i = 1; i <= n; ++i)b[i] = fast_IO::read();
	for (rg int i = 1; i != n; ++i)++mp[b[i + 1] - b[i]];
	for (rg int i = 1; i != n; ++i)if (!--mp[a[i + 1] - a[i]]) { puts("No"); return 0; }
	puts("Yes");
	return 0;
}


#include <bits/stdc++.h>
#define jh(x,y) x^=y^=x^=y
#define lowbit(x) (x&-x)
#define rg register
#define inl inline
typedef long long ll;
const int N = 1e5 + 5, mod = 1e9 + 7;
using namespace std;
namespace fast_IO {
	inl ll read()
	{
		rg ll num = 0;
		rg char ch;
		rg bool flag = false;
		while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
		if (ch == EOF)return ch; if (ch == '-')flag = true; else num = ch ^ 48;
		while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
			num = (num << 1) + (num << 3) + (ch ^ 48);
		if (flag)return -num; return num;
	}
	inl int chread(rg char s[])
	{
		rg int len = 0;
		rg char ch;
		while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
		s[len++] = ch;
		while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
			s[len++] = ch;
		s[len] = 0;
		return len;
	}
	inl ll max(rg ll a, rg ll b) { if (a > b)return a; return b; }
	inl ll min(rg ll a, rg ll b) { if (a < b)return a; return b; }
	void write(rg long long x) { if (x < 0)putchar('-'), x = -x; if (x >= 10)write(x / 10); putchar(x % 10 ^ 48); }
};
ll a[N], b[N];
map<ll, int>mp;

int main(void)
{
	rg int n = fast_IO::read();
	for (rg int i = 1; i <= n; ++i)a[i] = fast_IO::read();
	for (rg int i = 1; i <= n; ++i)b[i] = fast_IO::read();
	for (rg int i = 1; i != n; ++i)++mp[b[i + 1] - b[i]];
	for (rg int i = 1; i != n; ++i)if (!mp[a[i + 1] - a[i]]--) { puts("No"); return 0; }
	puts("Yes");
	return 0;
}


#include <bits/stdc++.h>
#define jh(x,y) x^=y^=x^=y
#define lowbit(x) (x&-x)
#define rg register
#define inl inline
typedef long long ll;
const int N = 1e5 + 5, mod = 1e9 + 7;
using namespace std;
namespace fast_IO {
	inl ll read()
	{
		rg ll num = 0;
		rg char ch;
		rg bool flag = false;
		while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
		if (ch == EOF)return ch; if (ch == '-')flag = true; else num = ch ^ 48;
		while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
			num = (num << 1) + (num << 3) + (ch ^ 48);
		if (flag)return -num; return num;
	}
	inl int chread(rg char s[])
	{
		rg int len = 0;
		rg char ch;
		while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
		s[len++] = ch;
		while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
			s[len++] = ch;
		s[len] = 0;
		return len;
	}
	inl ll max(rg ll a, rg ll b) { if (a > b)return a; return b; }
	inl ll min(rg ll a, rg ll b) { if (a < b)return a; return b; }
	void write(rg long long x) { if (x < 0)putchar('-'), x = -x; if (x >= 10)write(x / 10); putchar(x % 10 ^ 48); }
};
int a[N], b[N];
map<int, int>mp;

int main(void)
{
	rg int n = fast_IO::read();
	for (rg int i = 1; i <= n; ++i)a[i] = fast_IO::read();
	for (rg int i = 1; i <= n; ++i)b[i] = fast_IO::read();
	for (rg int i = 1; i != n; ++i)++mp[b[i + 1] - b[i]];
	for (rg int i = 1; i != n; ++i)if (!mp[a[i + 1] - a[i]]) { puts("No"); return 0; }
	puts("Yes");
	return 0;
}


#include <bits/stdc++.h>
#define jh(x,y) x^=y^=x^=y
#define lowbit(x) (x&-x)
#define rg register
#define inl inline
typedef long long ll;
const int N = 1e5 + 5, mod = 1e9 + 7;
using namespace std;
namespace fast_IO {
	inl ll read()
	{
		rg ll num = 0;
		rg char ch;
		rg bool flag = false;
		while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
		if (ch == EOF)return ch; if (ch == '-')flag = true; else num = ch ^ 48;
		while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
			num = (num << 1) + (num << 3) + (ch ^ 48);
		if (flag)return -num; return num;
	}
	inl int chread(rg char s[])
	{
		rg int len = 0;
		rg char ch;
		while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
		s[len++] = ch;
		while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
			s[len++] = ch;
		s[len] = 0;
		return len;
	}
	inl ll max(rg ll a, rg ll b) { if (a > b)return a; return b; }
	inl ll min(rg ll a, rg ll b) { if (a < b)return a; return b; }
	void write(rg long long x) { if (x < 0)putchar('-'), x = -x; if (x >= 10)write(x / 10); putchar(x % 10 ^ 48); }
};
ll a[N], b[N];
map<ll, int>mp;

int main(void)
{
	rg int n = fast_IO::read();
	for (rg int i = 1; i <= n; ++i)a[i] = fast_IO::read();
	for (rg int i = 1; i <= n; ++i)b[i] = fast_IO::read();
	if (a[1]!=b[1]||a[n]!=b[n]) { puts("No"); return 0; }
	for (rg int i = 1; i != n; ++i)++mp[b[i + 1] - b[i]];
	for (rg int i = 1; i != n; ++i)if (!mp[a[i + 1] - a[i]]--) { puts("No"); return 0; }
	puts("Yes");
	return 0;
}


#include <bits/stdc++.h>
#define int long long
#define MAXN 100000
using namespace std;

int n;
int c[MAXN+5], t[MAXN+5];
map <int, int> appr;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < c; i++) {
    cin >> c[i];
    if (i) appr[c[i]]++;
  }
  for (int i = 0; i < c; i++) {
    cin >> t[i];
    if (i) appr[t[i]]--;
  }
  bool tf = 1;
  for (auto i : appr) if (i.second != 0) tf = 0;
  if (tf && c[0] == t[0] && c[n-1] == t[n-1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


#include <bits/stdc++.h>
#define int long long
#define MAXN 100000
using namespace std;

int n;
int c[MAXN+5], t[MAXN+5];
map <int, int> appr;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    if (i) appr[c[i]]++;
  }
  for (int i = 0; i < n; i++) {
    cin >> t[i];
    if (i) appr[t[i]]--;
  }
  bool tf = 1;
  for (auto i : appr) if (i.second != 0) tf = 0;
  if (tf && c[0] == t[0] && c[n-1] == t[n-1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


#include <bits/stdc++.h>
#define int long long
#define MAXN 100000
using namespace std;

int n;
int c[MAXN+5], t[MAXN+5];
map <int, int> appr;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    if (i) appr[c[i]-c[i-1]]++;
  }
  for (int i = 0; i < n; i++) {
    cin >> t[i];
    if (i) appr[t[i]-t[i-1]]--;
  }
  bool tf = 1;
  for (auto i : appr) if (i.second != 0) tf = 0;
  if (tf && c[0] == t[0] && c[n-1] == t[n-1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn = 100000 + 10;

LL n,c[maxn],t[maxn],dc[maxn],dt[maxn];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  cin >> n;
  for(int i=1;i<=n;i++) cin >> c[i];
  for(int i=1;i<=n;i++) cin >> t[i];
  for(int i=1;i<n;i++)
  {
    dc[i] = c[i+1] - c[i];
    dt[i] = t[i+1] - t[i];
  }
  sort(dc+1,dc+n);
  sort(dt+1,dt+n);
  for(int i=1;i<n;i++) if(dc[i] != dt[i]) {cout << "No" << endl;return 0;}
  cout << "Yes" << endl;
  return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn = 100000 + 10;

LL n,c[maxn],t[maxn],dc[maxn],dt[maxn];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  cin >> n;
  for(int i=1;i<=n;i++) cin >> c[i];
  for(int i=1;i<=n;i++) cin >> t[i];
  if(n == 2)
  {
    if(c[1] == t[1] && c[2] == t[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
  }
  for(int i=1;i<n;i++)
  {
    dc[i] = c[i+1] - c[i];
    dt[i] = t[i+1] - t[i];
  }
  sort(dc+1,dc+n);
  sort(dt+1,dt+n);
  for(int i=1;i<n;i++) if(dc[i] != dt[i]) {cout << "No" << endl;return 0;}
  cout << "Yes" << endl;
  return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn = 100000 + 10;

LL n,c[maxn],t[maxn],dc[maxn],dt[maxn];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  cin >> n;
  for(int i=1;i<=n;i++) cin >> c[i];
  for(int i=1;i<=n;i++) cin >> t[i];
  if(n == 2)
  {
    if(c[1] == t[1] && c[2] == t[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
  }
  if(c[1] != t[1] || c[n] != t[n]) {cout << "No" << endl;return 0;}
  for(int i=1;i<n;i++)
  {
    dc[i] = c[i+1] - c[i];
    dt[i] = t[i+1] - t[i];
  }
  sort(dc+1,dc+n);
  sort(dt+1,dt+n);
  for(int i=1;i<n;i++) if(dc[i] != dt[i]) {cout << "No" << endl;return 0;}
  cout << "Yes" << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
typedef long long LL;

template <typename T>
inline void read(T &s) {
	s = 0;
	T w = 1, ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') w = -1; ch = getchar(); }
	while (isdigit(ch)) { s = (s << 1) + (s << 3) + (ch ^ 48); ch = getchar(); }
	s *= w;
}

int n;
int a[maxn], t[maxn];
int ca[maxn], ct[maxn];

int main() {
	freopen("1.in", "r", stdin);

	read(n);
	for (int i = 1; i <= n; ++i) read(a[i]);
	for (int i = 1; i <= n; ++i) read(t[i]);

	for (int i = 1; i <= n; ++i) {
		ca[i] = a[i] - a[i - 1];
		ct[i] = t[i] - t[i - 1];
	}
	sort(ca + 1, ca + n + 1);
	sort(ct + 1, ct + n + 1);
	for (int i = 1; i <= n; ++i) {
		if (ca[i] ^ ct[i]) {
			puts("No");
			exit(0);
		}
	}
	puts("Yes");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
typedef long long LL;

template <typename T>
inline void read(T &s) {
	s = 0;
	T w = 1, ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') w = -1; ch = getchar(); }
	while (isdigit(ch)) { s = (s << 1) + (s << 3) + (ch ^ 48); ch = getchar(); }
	s *= w;
}

int n;
int a[maxn], t[maxn];
int ca[maxn], ct[maxn];

int main() {
// 	freopen("1.in", "r", stdin);

	read(n);
	for (int i = 1; i <= n; ++i) read(a[i]);
	for (int i = 1; i <= n; ++i) read(t[i]);

	for (int i = 1; i <= n; ++i) {
		ca[i] = a[i] - a[i - 1];
		ct[i] = t[i] - t[i - 1];
	}
	sort(ca + 1, ca + n + 1);
	sort(ct + 1, ct + n + 1);
	for (int i = 1; i <= n; ++i) {
		if (ca[i] ^ ct[i]) {
			puts("No");
			exit(0);
		}
	}
	puts("Yes");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
typedef long long LL;

template <typename T>
inline void read(T &s) {
	s = 0;
	T w = 1, ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') w = -1; ch = getchar(); }
	while (isdigit(ch)) { s = (s << 1) + (s << 3) + (ch ^ 48); ch = getchar(); }
	s *= w;
}

int n;
int a[maxn], t[maxn];
int ca[maxn], ct[maxn];

int main() {
//	freopen("1.in", "r", stdin);
	read(n);
	for (int i = 1; i <= n; ++i) read(a[i]);
	for (int i = 1; i <= n; ++i) read(t[i]);

	if (a[1] ^ t[1]) {
		puts("No");
		exit(0);
	}

	for (int i = 1; i <= n; ++i) {
		ca[i] = a[i] - a[i - 1];
		ct[i] = t[i] - t[i - 1];
	}
	sort(ca + 1, ca + n + 1);
	sort(ct + 1, ct + n + 1);
	for (int i = 1; i <= n; ++i) {
		if (ca[i] ^ ct[i]) {
			puts("No");
			exit(0);
		}
	}
	puts("Yes");
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define bolt ios::sync_with_stdio(0)
#define light cin.tie(0);cout.tie(0)
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define MAXN 1000003
typedef long long ll;
using namespace std;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

// ll spff[MAXN];
//
// void spf(){
//     spff[0]=1;
//     spff[1]=1;
//     for(ll i=2;i<MAXN;i++){
//         if(i%2==0){
//             spff[i]=2;
//         }else spff[i]=i;
//     }
//     for(ll i=3;i*i<=MAXN;i++){
//         if(spff[i]==i){
//             for(ll j=i*i;j<=MAXN;j+=i){
//                 // if(spff[j]==j){
//                     spff[j]=i;
//                 // }
//             }
//         }
//     }
// }

int main(){
    bolt;
    ll n;
    cin>>n;
    ll a[100003],b[100003];
    forr(i,0,n){
        cin>>a[i];
    }
    forr(i,0,n){
        cin>>b[i];
    }
    if(a[0]!=b[0] || a[n-1]!=b[n-1]){
        cout<<"No\n";
    }else{
        ll ff=0;
        for(ll i=0;i<n-2;i++){
            ll p=a[i];
            ll f=0;
            for(ll j=i+2;j<n;j++){
                if(p+a[j]-a[j-1]==b[i+1]){
                    f=1;
                    break;
                }
            }
            if(f)
                continue;
            p=a[i+2];
            for(ll j=i;j>=0;j--){
                if(p+a[j]-a[j+1]==b[i+1]){
                    f=1;
                    break;
                }
            }
            if(f==0){
                // cout<<i<<" ";
                ff=1;
                break;
            }
        }
        if(ff)
            cout<<"No\n";
        else cout<<"Yes\n";
    }
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define bolt ios::sync_with_stdio(0)
#define light cin.tie(0);cout.tie(0)
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define MAXN 1000003
typedef long long ll;
using namespace std;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

// ll spff[MAXN];
//
// void spf(){
//     spff[0]=1;
//     spff[1]=1;
//     for(ll i=2;i<MAXN;i++){
//         if(i%2==0){
//             spff[i]=2;
//         }else spff[i]=i;
//     }
//     for(ll i=3;i*i<=MAXN;i++){
//         if(spff[i]==i){
//             for(ll j=i*i;j<=MAXN;j+=i){
//                 // if(spff[j]==j){
//                     spff[j]=i;
//                 // }
//             }
//         }
//     }
// }

int main(){
    bolt;
    ll n;
    cin>>n;
    ll a[100003],b[100003];
    forr(i,0,n){
        cin>>a[i];
    }
    forr(i,0,n){
        cin>>b[i];
    }
    if(a[0]!=b[0] || a[n-1]!=b[n-1]){
        cout<<"No\n";
    }else{
        ll ff=0;
        for(ll i=0;i<n-2;i++){
            ll p=a[i];
            ll f=0;
            for(ll j=i+2;j<n;j++){
                if(p+a[j]-a[j-1]==b[i+1]){
                    f=1;
                    break;
                }
            }
            if(f)
                continue;
            p=a[i];
            for(ll j=i;j>=0;j--){
                if(p+a[j]-a[j+1]==b[i+1]){
                    f=1;
                    break;
                }
            }
            if(f==0){
                // cout<<i<<" ";
                // ff=1;
                break;
            }
        }
        if(ff)
            cout<<"No\n";
        else cout<<"Yes\n";
    }
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define bolt ios::sync_with_stdio(0)
#define light cin.tie(0);cout.tie(0)
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define MAXN 1000003
typedef long long ll;
using namespace std;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

// ll spff[MAXN];
//
// void spf(){
//     spff[0]=1;
//     spff[1]=1;
//     for(ll i=2;i<MAXN;i++){
//         if(i%2==0){
//             spff[i]=2;
//         }else spff[i]=i;
//     }
//     for(ll i=3;i*i<=MAXN;i++){
//         if(spff[i]==i){
//             for(ll j=i*i;j<=MAXN;j+=i){
//                 // if(spff[j]==j){
//                     spff[j]=i;
//                 // }
//             }
//         }
//     }
// }

int main(){
    bolt;
    ll n;
    cin>>n;
    ll a[100003],b[100003];
    forr(i,0,n){
        cin>>a[i];
    }
    forr(i,0,n){
        cin>>b[i];
    }
    if(a[0]!=b[0] || a[n-1]!=b[n-1]){
        cout<<"No\n";
    }else{
        ll ff=0;
        for(ll i=0;i<n-2;i++){
            ll p=a[i];
            ll f=0;
            for(ll j=i+2;j<n;j++){
                if(p+a[j]-a[j-1]==b[i+1]){
                    f=1;
                    break;
                }
            }
            if(f)
                continue;
            p=a[i+2];
            for(ll j=i;j>=0;j--){
                if(p+a[j]-a[j+1]==b[i+1]){
                    f=1;
                    break;
                }
            }
            if(f==0){
                // cout<<i<<" ";
                // ff=1;
                break;
            }
        }
        if(ff)
            cout<<"No\n";
        else cout<<"Yes\n";
    }
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define bolt ios::sync_with_stdio(0)
#define light cin.tie(0);cout.tie(0)
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define MAXN 1000003
typedef long long ll;
using namespace std;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

// ll spff[MAXN];
//
// void spf(){
//     spff[0]=1;
//     spff[1]=1;
//     for(ll i=2;i<MAXN;i++){
//         if(i%2==0){
//             spff[i]=2;
//         }else spff[i]=i;
//     }
//     for(ll i=3;i*i<=MAXN;i++){
//         if(spff[i]==i){
//             for(ll j=i*i;j<=MAXN;j+=i){
//                 // if(spff[j]==j){
//                     spff[j]=i;
//                 // }
//             }
//         }
//     }
// }

int main(){
    bolt;
    ll n;
    cin>>n;
    ll a[100003],b[100003];
    forr(i,0,n){
        cin>>a[i];
    }
    forr(i,0,n){
        cin>>b[i];
    }
    if(a[0]!=b[0] || a[n-1]!=b[n-1]){
        cout<<"No\n";
    }else{
cout<<"Yes\n";
    }
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define bolt ios::sync_with_stdio(0)
#define light cin.tie(0);cout.tie(0)
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define MAXN 1000003
typedef long long ll;
using namespace std;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

// ll spff[MAXN];
//
// void spf(){
//     spff[0]=1;
//     spff[1]=1;
//     for(ll i=2;i<MAXN;i++){
//         if(i%2==0){
//             spff[i]=2;
//         }else spff[i]=i;
//     }
//     for(ll i=3;i*i<=MAXN;i++){
//         if(spff[i]==i){
//             for(ll j=i*i;j<=MAXN;j+=i){
//                 // if(spff[j]==j){
//                     spff[j]=i;
//                 // }
//             }
//         }
//     }
// }

int main(){
    bolt;
    ll n;
    cin>>n;
    ll a[100003],b[100003];
    forr(i,0,n){
        cin>>a[i];
    }
    forr(i,0,n){
        cin>>b[i];
    }
    if(a[0]!=b[0] || a[n-1]!=b[n-1]){
        cout<<"No\n";
    }else{
        vector<ll>v1,v2;
        forr(i,1,n){
            v1.pb((a[i]-a[i-1]));
            v2.pb((b[i]-b[i-1]));
        }
        sort(all(v1));
        sort(all(v2));
        if(v1==v2){
            cout<<"Yes\n";
        }else cout<<"No\n";
    }
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define bolt ios::sync_with_stdio(0)
#define light cin.tie(0);cout.tie(0)
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define MAXN 1000003
typedef long long ll;
using namespace std;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

// ll spff[MAXN];
//
// void spf(){
//     spff[0]=1;
//     spff[1]=1;
//     for(ll i=2;i<MAXN;i++){
//         if(i%2==0){
//             spff[i]=2;
//         }else spff[i]=i;
//     }
//     for(ll i=3;i*i<=MAXN;i++){
//         if(spff[i]==i){
//             for(ll j=i*i;j<=MAXN;j+=i){
//                 // if(spff[j]==j){
//                     spff[j]=i;
//                 // }
//             }
//         }
//     }
// }

int main(){
    bolt;
    ll n;
    cin>>n;
    ll a[100003],b[100003];
    forr(i,0,n){
        cin>>a[i];
    }
    forr(i,0,n){
        cin>>b[i];
    }
    if(a[0]!=b[0] || a[n-1]!=b[n-1]){
        cout<<"No\n";
    }else{
        vector<ll>v1,v2;
        forr(i,1,n){
            v1.pb(a[i]-a[i-1]);
            v2.pb(b[i]-b[i-1]);
            sort(all(v1));
            sort(all(v2));
            if(v1==v2){
                cout<<"Yes\n";
            }else cout<<"No\n";
        }
    }
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define bolt ios::sync_with_stdio(0)
#define light cin.tie(0);cout.tie(0)
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define MAXN 1000003
typedef long long ll;
using namespace std;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

// ll spff[MAXN];
//
// void spf(){
//     spff[0]=1;
//     spff[1]=1;
//     for(ll i=2;i<MAXN;i++){
//         if(i%2==0){
//             spff[i]=2;
//         }else spff[i]=i;
//     }
//     for(ll i=3;i*i<=MAXN;i++){
//         if(spff[i]==i){
//             for(ll j=i*i;j<=MAXN;j+=i){
//                 // if(spff[j]==j){
//                     spff[j]=i;
//                 // }
//             }
//         }
//     }
// }

int main(){
    bolt;
    ll n;
    cin>>n;
    ll a[100003],b[100003];
    forr(i,0,n){
        cin>>a[i];
    }
    forr(i,0,n){
        cin>>b[i];
    }
    if(a[0]!=b[0] || a[n-1]!=b[n-1]){
        cout<<"No\n";
    }else{
        ll ff=0;
        for(ll i=0;i<n-2;i++){
            ll p=a[i];
            ll f=0;
            for(ll j=i+2;j<n;j++){
                if(p+a[j]-a[j-1]==b[i+1]){
                    f=1;
                    break;
                }
            }
            if(f)
                continue;
            p=a[i];
            for(ll j=i;j>=0;j--){
                if(p+a[j]-a[j+1]==b[i+1]){
                    f=1;
                    break;
                }
            }
            if(f==0){
                // cout<<i<<" ";
                ff=1;
                break;
            }
        }
        if(ff)
            cout<<"No\n";
        else cout<<"Yes\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=1000005;
int n;
ll a[M],b[M];
int main(){
    scanf("%d",&n);
    for(int i=1; i<=n; i++){
        int v; scanf("%d",&v);
        a[i]=v;
    }
    for(int i=1; i<=n; i++){
        int v; scanf("%d",&v);
        b[i]=v;
    }
    int f=1;
    while(f){
        f=0;
        for(int i=1; i<=n-2; i++){
            if(a[i]+a[i+2]>a[i+1]*2){
                a[i+1]=a[i]+a[i+2]-a[i+1];
                f=1;
            }
        }
    }
    f=1;
    while(f){
        f=0;
        for(int i=1; i<=n-2; i++){
            if(b[i]+b[i+2]>b[i+1]*2){
                b[i+1]=b[i]+b[i+2]-b[i+1];
                f=1;
            }
        }
    }
    //for(int i=1; i<=n; i++) cout<<a[i]<<" "; cout<<endl;
    //for(int i=1; i<=n; i++) cout<<b[i]<<" "; cout<<endl;
    f=1;
    for(int i=1; i<=n; i++) if(a[i]!=b[i]) f=0;
    if(f) printf("Yes\n");
    else printf("No\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=1000005;
int n,a[M],b[M],c[M],d[M];
int main(){
    scanf("%d",&n);
    for(int i=1; i<=n; i++){
        scanf("%d",&a[i]); c[i]=a[i]-a[i-1];
    }
    for(int i=1; i<=n; i++){
        scanf("%d",&b[i]); d[i]=b[i]-b[i-1];
    }
    sort(c+1,c+1+n);
    sort(d+1,d+1+n);
    int f=1;
    for(int i=1; i<=n; i++) if(a[i]!=b[i]) f=0;
    if(f && a[1]==b[1] && a[n]==b[n]) printf("Yes\n");
    else printf("No\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=1000005;
int n,a[M],b[M],c[M],d[M];
int main(){
    scanf("%d",&n);
    for(int i=1; i<=n; i++){
        scanf("%d",&a[i]); c[i]=a[i]-a[i-1];
    }
    for(int i=1; i<=n; i++){
        scanf("%d",&b[i]); d[i]=b[i]-b[i-1];
    }
    sort(c+1,c+1+n);
    sort(d+1,d+1+n);
    int f=1;
    for(int i=1; i<=n; i++) if(c[i]!=d[i]) f=0;
    if(f && a[1]==b[1] && a[n]==b[n]) printf("Yes\n");
    else printf("No\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=1000005;
int n,a[M],b[M],c[M],d[M];
int main(){
    scanf("%d",&n);
    for(int i=1; i<=n; i++){
        scanf("%d",&a[i]); if(i>1) c[i-1]=a[i]-a[i-1];
    }
    for(int i=1; i<=n; i++){
        scanf("%d",&b[i]); if(i>1) d[i-1]=b[i]-b[i-1];
    }
    sort(c+1,c+n);
    sort(d+1,d+n);
    int f=1;
    for(int i=1; i<=n-1; i++) if(c[i]!=d[i]) f=0;
    if(f) printf("Yes\n");
    else printf("No\n");
    return 0;
}