#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef unsigned long long ull;

#define X first
#define Y second
#define pb push_back
#define EL printf("\n")
#define sz(A) (int)A.size()
#define FOR(i, l, r) for (int i = l; i <= r; i++)
#define FOD(i, r, l) for (int i = r; i >= l; i--)
#define faster                                                                 \
    ios_base::sync_with_stdio(false);                                          \
    cin.tie(NULL);                                                             \
    cout.tie(NULL);

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

int main() {

    faster;

    cin >> n;
    FOR(i, 1, n) cin >> a[i];
    FOR(i, 1, n) cin >> b[i];

    if (a[1] != b[1] || a[n] != b[n]) {
        cout << "No\n";
        return 0;
    }

    set<int> diffA, diffB;
    FOR(i, 1, n - 1) {
        diffA.insert(a[i + 1] - a[i]);
        diffB.insert(b[i + 1] - b[i]);
    }

    if (diffA == diffB) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int infint = (ll)1e9 + 7;
const ll inf = (ll)1e18;
const int MAXN = (int)1e5 + 3;
ll n, c[MAXN], t[MAXN];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> 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])
		return cout << "No", 0;
	for (int i = 0; i < n - 1; i++)
		c[i] = c[i] - c[i + 1];
	for (int i = 0; i < n - 1; i++)
		t[i] = t[i] - t[i + 1];

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


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int infint = (ll)1e9 + 7;
const ll inf = (ll)1e18;
const int MAXN = (int)1e5 + 3;
ll n, c[MAXN], t[MAXN];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> c[i];
	for (int i = 0; i < n; i++)
		cin >> t[i];

	if(n == 2)
		return cout << "No", 0;
	for (int i = 0; i < n - 1; i++)
		c[i] = c[i] - c[i + 1];
	for (int i = 0; i < n - 1; i++)
		t[i] = t[i] - t[i + 1];

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


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int infint = (ll)1e9 + 7;
const ll inf = (ll)1e18;
const int MAXN = (int)1e5 + 3;
ll n, c[MAXN], t[MAXN];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> 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])
		return cout << "No", 0;
	cout << "Yes";
	for (int i = 0; i < n - 1; i++)
		c[i] = c[i] - c[i + 1];
	for (int i = 0; i < n - 1; i++)
		t[i] = t[i] - t[i + 1];

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


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int infint = (ll)1e9 + 7;
const ll inf = (ll)1e18;
const int MAXN = (int)1e5 + 3;
int n, c[MAXN], t[MAXN];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	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++)
		c[i] = c[i] - c[i + 1];
	for (int i = 0; i < n - 1; i++)
		t[i] = t[i] - t[i + 1];
	sort(c, c + n - 1);
	sort(t, t + n - 1);
	for (int i = 0; i < n - 1; i++)
		if(c[i] != t[i])
			return cout << "No", 0;
	cout << "Yes";
}


#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fe first
#define se second
#define endl "\n"
#define pii pair<int,int>
#define PI  3.14159265358979323846

const int N=1e5+10;
int a[N],b[N];

int main()
{ cool;
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  	 cin>>a[i];
   for(int i=0;i<n;i++)
     cin>>b[i];

  vector<int >v1,v2;
  for(int i=0;i<n-1;i++)
    { v1.pb(a[i+1]-a[i]);
      v2.pb(b[i+1]-b[i]);
    }

    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
  if(v1==v2 && a[0]==b[0] && a[n-1]==b[n-1])
   cout<<"Yes\n";
   else
     cout<<"No\n";

     return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fe first
#define se second
#define endl "\n"
#define pii pair<int,int>
#define PI  3.14159265358979323846

const int N=1e5+10;
int a[N],b[N];

int main()
{ cool;
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  	 cin>>a[i];
   for(int i=0;i<n;i++)
     cin>>b[i];

  vector<int >v1,v2;
  for(int i=0;i<n-1;i++)
    { v1.pb(a[i+1]-a[i]);
      v2.pb(b[i+1]-b[i]);
    }

    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
  if(v1!=v2)
   cout<<"No\n";
   else
     cout<<"Yes\n";

     return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fe first
#define se second
#define endl "\n"
#define pii pair<int,int>
#define PI  3.14159265358979323846

const int N=1e5+10;
int a[N],b[N];

int main()
{ cool;
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  	 cin>>a[i];
   for(int i=0;i<n;i++)
     cin>>b[i];

  vector<int >v1,v2;
  for(int i=0;i<n-1;i++)
    { v1.pb(a[i+1]-a[i]);
      v2.pb(b[i+1]-b[i]);
    }

    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
  if(v1==v2 && a[0]=b[0] && a[n-1]==b[n-1])
   cout<<"Yes\n";
   else
     cout<<"No\n";

     return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fe first
#define se second
#define endl "\n"
#define pii pair<int,int>
#define PI  3.14159265358979323846

const int N=1e5+10;
int a[N],b[N];

int main()
{ cool;
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  	 cin>>a[i];
   for(int i=0;i<n;i++)
     cin>>b[i];

  vector<int >v1,v2;
  for(int i=0;i<n-1;i++)
    { v1.pb(a[i+1]-a[i]);
      v2.pb(b[i+1]-b[i]);
    }

    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
  if(v1!=v2 && a[0]==b[0] && a[n-1]==b[n-1])
   cout<<"No\n";
   else
     cout<<"Yes\n";

     return 0;

}


//# pragma GCC optimize ("O0")
# pragma GCC optimize ("Ofast")
//# pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define UN -1
#define VIS -2
#define EX -3
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define pob pop_back()
#define puf push_front
#define pof pop_front()
#define clr(a) (a).clear()
#define sz(a) (int)(a).size()
#define forn(t, n) for(int t = 0; t < n; t++)
#define foren(t, n) for(int t = 1; t <= n; t++)
#define llm LONG_LONG_MAX
#define llmn LONG_LONG_MIN
#define intm INT_MAX
#define intmn INT_MIN
#define dblm DBL_MAX
#define dblmn DBL_MIN
#define mod 1000000007
#define mod2 1000000009
#define mil 1111111
#define bil 1111111111
#define pi M_PI
#define euler 2.718281828459
#define eps 1e-12
#define degrad (pi/180.0)
#define raddeg (180.0/pi)
#define uset unordered_set
#define umap unordered_map
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
typedef vector<ll> vll; typedef pair<ll, ll> pll; typedef vector<pll> vpll;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vi> vvi;
typedef pair<int, ii> iii; typedef pair<ii, ii> iiii; typedef pair<ll, pll> tll;
typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<vc> vvc;
typedef vector<bool> vb; typedef vector<vb> vvb; typedef queue<int> qi; typedef queue<ll> qll;
typedef queue<ii> qii; typedef vector<tll> vtll; typedef vector<iii> viii; typedef pair<pll, pll> ppll;
typedef priority_queue<int> pqi; typedef priority_queue<ll> pqll;
typedef pair<int, ii> iii; typedef vector<string> vs;
typedef vector<double> vd; typedef pair<double, double> dd; typedef vector<dd> vdd; typedef pair<ii, int> riii;
typedef vector<vector<double> > vvd; typedef vector<vvi> vvvi;

template <class T> ostream& operator << (ostream &out, const vector<T> &v) {
    for (auto it = v.begin(); it != v.end(); ++it) { if (it == v.begin()) out << *it; else out << " " << *it; } return out;
}
//ifstream in("/home/danza/CLionProjects/codeforces/in.in");
//ofstream out("/home/danza/CLionProjects/codeforces/out2.out");
//#define cin in
//#define cout out

int main() { fio
    int n;
    cin >> n;
    vi a(n), b(n);
    forn(i, n)
        cin >> a[i];
    forn(i, n)
        cin >> b[i];
    set<int> sta, stb;
    forn(i, n - 1) {
        sta.insert(a[i + 1] - a[i]);
        stb.insert(b[i + 1] - b[i]);
    }
    if(sta == stb)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


//# pragma GCC optimize ("O0")
# pragma GCC optimize ("Ofast")
//# pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define UN -1
#define VIS -2
#define EX -3
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define pob pop_back()
#define puf push_front
#define pof pop_front()
#define clr(a) (a).clear()
#define sz(a) (int)(a).size()
#define forn(t, n) for(int t = 0; t < n; t++)
#define foren(t, n) for(int t = 1; t <= n; t++)
#define llm LONG_LONG_MAX
#define llmn LONG_LONG_MIN
#define intm INT_MAX
#define intmn INT_MIN
#define dblm DBL_MAX
#define dblmn DBL_MIN
#define mod 1000000007
#define mod2 1000000009
#define mil 1111111
#define bil 1111111111
#define pi M_PI
#define euler 2.718281828459
#define eps 1e-12
#define degrad (pi/180.0)
#define raddeg (180.0/pi)
#define uset unordered_set
#define umap unordered_map
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
typedef vector<ll> vll; typedef pair<ll, ll> pll; typedef vector<pll> vpll;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vi> vvi;
typedef pair<int, ii> iii; typedef pair<ii, ii> iiii; typedef pair<ll, pll> tll;
typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<vc> vvc;
typedef vector<bool> vb; typedef vector<vb> vvb; typedef queue<int> qi; typedef queue<ll> qll;
typedef queue<ii> qii; typedef vector<tll> vtll; typedef vector<iii> viii; typedef pair<pll, pll> ppll;
typedef priority_queue<int> pqi; typedef priority_queue<ll> pqll;
typedef pair<int, ii> iii; typedef vector<string> vs;
typedef vector<double> vd; typedef pair<double, double> dd; typedef vector<dd> vdd; typedef pair<ii, int> riii;
typedef vector<vector<double> > vvd; typedef vector<vvi> vvvi;

template <class T> ostream& operator << (ostream &out, const vector<T> &v) {
    for (auto it = v.begin(); it != v.end(); ++it) { if (it == v.begin()) out << *it; else out << " " << *it; } return out;
}
//ifstream in("/home/danza/CLionProjects/codeforces/in.in");
//ofstream out("/home/danza/CLionProjects/codeforces/out2.out");
//#define cin in
//#define cout out

int main() { fio
    ll n;
    cin >> n;
    vll a(n), b(n);
    forn(i, n)
        cin >> a[i];
    forn(i, n)
        cin >> b[i];
    if(a[0] != b[0]) {
        cout << "No\n";
        return 0;
    }
    multiset<ll> sta, stb;
    forn(i, n - 1) {
        sta.insert(a[i + 1] - a[i]);
        stb.insert(b[i + 1] - b[i]);
    }
    if(sta == stb)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


//# pragma GCC optimize ("O0")
# pragma GCC optimize ("Ofast")
//# pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define UN -1
#define VIS -2
#define EX -3
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define pob pop_back()
#define puf push_front
#define pof pop_front()
#define clr(a) (a).clear()
#define sz(a) (int)(a).size()
#define forn(t, n) for(int t = 0; t < n; t++)
#define foren(t, n) for(int t = 1; t <= n; t++)
#define llm LONG_LONG_MAX
#define llmn LONG_LONG_MIN
#define intm INT_MAX
#define intmn INT_MIN
#define dblm DBL_MAX
#define dblmn DBL_MIN
#define mod 1000000007
#define mod2 1000000009
#define mil 1111111
#define bil 1111111111
#define pi M_PI
#define euler 2.718281828459
#define eps 1e-12
#define degrad (pi/180.0)
#define raddeg (180.0/pi)
#define uset unordered_set
#define umap unordered_map
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
typedef vector<ll> vll; typedef pair<ll, ll> pll; typedef vector<pll> vpll;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vi> vvi;
typedef pair<int, ii> iii; typedef pair<ii, ii> iiii; typedef pair<ll, pll> tll;
typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<vc> vvc;
typedef vector<bool> vb; typedef vector<vb> vvb; typedef queue<int> qi; typedef queue<ll> qll;
typedef queue<ii> qii; typedef vector<tll> vtll; typedef vector<iii> viii; typedef pair<pll, pll> ppll;
typedef priority_queue<int> pqi; typedef priority_queue<ll> pqll;
typedef pair<int, ii> iii; typedef vector<string> vs;
typedef vector<double> vd; typedef pair<double, double> dd; typedef vector<dd> vdd; typedef pair<ii, int> riii;
typedef vector<vector<double> > vvd; typedef vector<vvi> vvvi;

template <class T> ostream& operator << (ostream &out, const vector<T> &v) {
    for (auto it = v.begin(); it != v.end(); ++it) { if (it == v.begin()) out << *it; else out << " " << *it; } return out;
}
//ifstream in("/home/danza/CLionProjects/codeforces/in.in");
//ofstream out("/home/danza/CLionProjects/codeforces/out2.out");
//#define cin in
//#define cout out

int main() { fio
    int n;
    cin >> n;
    vi a(n), b(n);
    forn(i, n)
        cin >> a[i];
    forn(i, n)
        cin >> b[i];
    if(a[0] != b[0]) {
        cout << "No\n";
        return 0;
    }
    set<int> sta, stb;
    forn(i, n - 1) {
        sta.insert(a[i + 1] - a[i]);
        stb.insert(b[i + 1] - b[i]);
    }
    if(sta == stb)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define UN -1
#define VIS -2
#define EX -3
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define pob pop_back()
#define puf push_front
#define pof pop_front()
#define clr(a) (a).clear()
#define sz(a) (int)(a).size()
#define forn(t, n) for(int t = 0; t < n; t++)
#define foren(t, n) for(int t = 1; t <= n; t++)
#define llm LONG_LONG_MAX
#define llmn LONG_LONG_MIN
#define intm INT_MAX
#define intmn INT_MIN
#define dblm DBL_MAX
#define dblmn DBL_MIN
#define mod 1000000007
#define mod2 1000000009
#define pi M_PI
#define eps 1e-9
#define degrad (pi/180.0)
#define raddeg (180.0/pi)
#define sqr(a) ((a) * (a))
#define uset unordered_set
#define umap unordered_map
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
typedef vector<ll> vll; typedef pair<ll, ll> pll; typedef vector<pll> vpll;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vi> vvi;
typedef pair<int, ii> iii; typedef pair<ii, ii> iiii; typedef pair<ll, pll> tll;
typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<vc> vvc;
typedef vector<bool> vb; typedef vector<vb> vvb; typedef queue<int> qi; typedef queue<ll> qll;
typedef queue<ii> qii; typedef vector<tll> vtll; typedef vector<iii> viii; typedef pair<pll, pll> ppll;
typedef priority_queue<int> pqi; typedef priority_queue<ll> pqll;
typedef pair<int, ii> iii; typedef vector<string> vs;
typedef vector<double> vd; typedef pair<double, double> dd; typedef vector<dd> vdd; typedef pair<ii, int> riii;
typedef vector<vector<double> > vvd; typedef vector<vvi> vvvi;

template <class T> ostream& operator << (ostream &out, const vector<T> &v) {
    for(auto it = v.begin(); it != v.end(); ++it) { if (it == v.begin()) out << *it; else out << " " << *it; } return out;
}

//ifstream in("/home/danza/CLionProjects/codeforces/in.in");
//ofstream out("/home/danza/CLionProjects/codeforces/out2.out");
//#define cin in
//#define cout out

int main() { fio
    ll n;
    cin >> n;
    vll a(n), b(n);
    vector<set<ll>> acc(n);
    forn(i, n) {
        cin >> a[i];
        acc[i].insert(a[i]);
    }
    forn(i, n)
        cin >> b[i];
    ll left, right;
    foren(i, n - 2) {
        left = a[i - 1];
        for(int j = i; j < n; j++) {
            ll now = left + a[j + 1] - a[j];
            acc[j].insert(now);
            left = now;
        }
    }
    for(int i = n - 2; i > 0; i--) {
        right = a[i + 1];
        for(int j = i; j > 0; j--) {
            ll now = right + a[j - 1] - a[j];
            acc[j].insert(now);
            right = now;
        }
    }
    forn(i, n) {
        if(acc[i].find(b[i]) == acc[i].end()) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";

    return 0;
}


//# pragma GCC optimize ("O0")
# pragma GCC optimize ("Ofast")
//# pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define UN -1
#define VIS -2
#define EX -3
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define pob pop_back()
#define puf push_front
#define pof pop_front()
#define clr(a) (a).clear()
#define sz(a) (int)(a).size()
#define forn(t, n) for(int t = 0; t < n; t++)
#define foren(t, n) for(int t = 1; t <= n; t++)
#define llm LONG_LONG_MAX
#define llmn LONG_LONG_MIN
#define intm INT_MAX
#define intmn INT_MIN
#define dblm DBL_MAX
#define dblmn DBL_MIN
#define mod 1000000007
#define mod2 1000000009
#define mil 1111111
#define bil 1111111111
#define pi M_PI
#define euler 2.718281828459
#define eps 1e-12
#define degrad (pi/180.0)
#define raddeg (180.0/pi)
#define uset unordered_set
#define umap unordered_map
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
typedef vector<ll> vll; typedef pair<ll, ll> pll; typedef vector<pll> vpll;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vi> vvi;
typedef pair<int, ii> iii; typedef pair<ii, ii> iiii; typedef pair<ll, pll> tll;
typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<vc> vvc;
typedef vector<bool> vb; typedef vector<vb> vvb; typedef queue<int> qi; typedef queue<ll> qll;
typedef queue<ii> qii; typedef vector<tll> vtll; typedef vector<iii> viii; typedef pair<pll, pll> ppll;
typedef priority_queue<int> pqi; typedef priority_queue<ll> pqll;
typedef pair<int, ii> iii; typedef vector<string> vs;
typedef vector<double> vd; typedef pair<double, double> dd; typedef vector<dd> vdd; typedef pair<ii, int> riii;
typedef vector<vector<double> > vvd; typedef vector<vvi> vvvi;

template <class T> ostream& operator << (ostream &out, const vector<T> &v) {
    for (auto it = v.begin(); it != v.end(); ++it) { if (it == v.begin()) out << *it; else out << " " << *it; } return out;
}
//ifstream in("/home/danza/CLionProjects/codeforces/in.in");
//ofstream out("/home/danza/CLionProjects/codeforces/out2.out");
//#define cin in
//#define cout out

int main() { fio
    ll n;
    cin >> n;
    vll a(n), b(n);
    forn(i, n)
        cin >> a[i];
    forn(i, n)
        cin >> b[i];
    if(a[0] != b[0]) {
        cout << "No\n";
        return 0;
    }
    set<ll> sta, stb;
    forn(i, n - 1) {
        sta.insert(a[i + 1] - a[i]);
        stb.insert(b[i + 1] - b[i]);
    }
    if(sta == stb)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long c[100010],c1[100010],t[10010],t1[100010];
int main(){
    int n;
    cin>>n;
    for (int i=1;i<=n;i++) {
        cin>>c[i];
        c1[i]=c[i]-c[i-1];
    }
    for (int i=1;i<=n;i++) {
        cin>>t[i];
        t1[i]=t[i]-t[i-1];
    }
    sort(c1+1,c1+n+1);
    sort(t1+1,t1+n+1);
    bool flag=true;
    for (int i=1;i<=n;i++)
        if (c1[i]!=t1[i])
            flag=false;
    if (flag && c[1]==t[1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long c[100010],c1[100010],t[10010],t1[100010];
int main(){
    int n;
    cin>>n;
    for (int i=1;i<=n;i++) {
        cin>>c[i];
        c1[i]=c[i]-c[i-1];
    }
    for (int i=1;i<=n;i++) {
        cin>>t[i];
        t1[i]=t[i]-t[i-1];
    }
    sort(c1+1,c1+n+1);
    sort(t1+1,t1+n+1);
    bool flag=true;
    for (int i=1;i<=n;i++)
        if (c1[i]!=t1[i])
            flag=false;
    if (flag && c[1]==t[1] && c[n]==t[n]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long c[100010],c1[100010],t[100010],t1[100010];
int main(){
    int n;
    cin>>n;
    for (int i=1;i<=n;i++) {
        cin>>c[i];
        c1[i]=c[i]-c[i-1];
    }
    for (int i=1;i<=n;i++) {
        cin>>t[i];
        t1[i]=t[i]-t[i-1];
    }
    sort(c1+1,c1+n+1);
    sort(t1+1,t1+n+1);
    bool flag=true;
    for (int i=1;i<=n;i++)
        if (c1[i]!=t1[i])
            flag=false;
    if (flag && c[1]==t[1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int c[100010],c1[100010],t[10010],t1[100010];
int main(){
    int n;
    cin>>n;
    for (int i=1;i<=n;i++) {
        cin>>c[i];
        c1[i]=c[i]-c[i-1];
    }
    for (int i=1;i<=n;i++) {
        cin>>t[i];
        t1[i]=t[i]-t[i-1];
    }
    sort(c1+1,c1+n+1);
    sort(t1+1,t1+n+1);
    bool flag=true;
    for (int i=1;i<=n;i++)
        if (c1[i]!=t1[i])
            flag=false;
    if (flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

ll c[N], d[N];

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> c[i];
	}
	for (int i = 1; i <= n; ++i) {
		cin >> d[i];
	}
	vector<ll> v1, v2;
	for (int i = 2; i <= n; ++i) {
		v1.pb(c[i] - c[i - 1]);
		v2.pb(d[i] - d[i - 1]);
	}
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
    int cnt=0;
	if (v1==v2 and c[1] == d[1]) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}


#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

ll c[N], d[N];

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> c[i];
	}
	for (int i = 1; i <= n; ++i) {
		cin >> d[i];
	}
	vector<ll> v1, v2;
	for (int i = 2; i <= n; ++i) {
		v1.pb(c[i] - c[i - 1]);
		v2.pb(d[i] - d[i - 1]);
	}
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
          int cnt=0;
          for (int i = 1; i <= n; i++)
          {
              if(v1[i]==v2[i])
              {
                      cnt++;
               }
          }
	if (cnt==n and c[1] == d[1]) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}


#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

ll c[N], d[N];

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> c[i];
	}
	for (int i = 1; i <= n; ++i) {
		cin >> d[i];
	}
	vector<ll> v1, v2;
	for (int i = 2; i <= n; ++i) {
		v1.pb(c[i] - c[i - 1]);
		v2.pb(d[i] - d[i - 1]);
	}
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
    int cnt=0;
    for (int i = 1; i <= n; ++i) {
		if(v1[i]==v2[i])
        {
            cnt++;
        }
	}
	if (cnt==n and c[1] == d[1]) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  vector<int> x, y;
  for (int i = 0; i < n - 1; i++) {
    x.push_back(a[i + 1] - a[i]);
    y.push_back(b[i + 1] - b[i]);
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  if (a[0] != b[0] || a[n - 1] != b[n - 1]) {
    cout << "No" << '\n';
    return 0;
  }
  cout << "Yes" << '\n';
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  vector<int> x, y;
  for (int i = 0; i < n - 1; i++) {
    x.push_back(a[i + 1] - a[i]);
    y.push_back(b[i + 1] - b[i]);
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  if (a[0] != b[0] || a[n - 1] != b[n - 1] || x != y) {
    cout << "No" << '\n';
    return 0;
  }
  cout << "Yes" << '\n';
  return 0;
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007

//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int n;
        cin >> n;
        vector<int> a(n);
        vector<int> t(n);
        rep(i, 0, n) cin >> a[i];
        rep(i, 0, n) cin >> t[i];

        if (a[0] != t[0]) {
            cout << "No" << endl;
            return;
        }

        vector<int> da;
        vector<int> dt;
        for (int i = 1; i < n; ++i) {
            da.push_back(a[i] - a[i - 1]);
            dt.push_back(t[i] - t[i - 1]);
        }

        sort(all(da));
        sort(all(dt));
        if (da == dt) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();

    return 0;
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007

//ここから編集する
class Solve {
public:
    void input() {

    }

    void left(vector<ll> &vec) {
        int n = vec.size();
        for (int i = 1; i < n - 1; i += 2) {
            vec[i] = max(vec[i], vec[i - 1] + vec[i + 1] - vec[i]);
        }
        for (int i = 2; i < n - 1; i += 2) {
            vec[i] = max(vec[i], vec[i - 1] + vec[i + 1] - vec[i]);
        }
    }

    void solve() {
        input();
        int n;
        cin >> n;

        vector<ll> c(n);
        vector<ll> t(n);

        rep(i, 0, n) cin >> c[i];
        rep(i, 0, n) cin >> t[i];

        for (int i = 0; i < 10; ++i) {
            left(c);
            left(t);
        }

        if (c == t) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }

    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();

    return 0;
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007

//ここから編集する
class Solve {
public:
    void input() {

    }

    bool left(vector<ll> &vec) {
        int n = vec.size();
        bool ret = false;
        for (int i = 1; i < n - 1; i += 2) {
            if (vec[i] < vec[i - 1] + vec[i + 1] - vec[i]) ret = true;
            vec[i] = max(vec[i], vec[i - 1] + vec[i + 1] - vec[i]);
        }
        for (int i = 2; i < n - 1; i += 2) {
            if (vec[i] < vec[i - 1] + vec[i + 1] - vec[i]) ret = true;
            vec[i] = max(vec[i], vec[i - 1] + vec[i + 1] - vec[i]);
        }
        return ret;
    }

    void solve() {
        input();
        int n;
        cin >> n;

        vector<ll> c(n);
        vector<ll> t(n);

        rep(i, 0, n) cin >> c[i];
        rep(i, 0, n) cin >> t[i];

        while(left(c)){

        }
        while(left(t)){

        }
//        for (int i = 0; i < 10; ++i) {
//            left(c);
//            left(t);
//        }

        if (c == t) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }

    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    vector<long long int > a(n);

    vector<long long int > b(n);
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(long long int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    if(n==2)
    {
        if(a[0]!=b[0] || a[1]!=[b]1])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    for(long long int i=n-1;i>0;i--)
    {

        a[i]=a[i]-a[i-1];
    }

    for(long long int i=n-1;i>0;i--)
    {
        b[i]=b[i]-b[i-1];
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    for(long long int i=0;i<n;i++)
    {
        if(a[i]!=b[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    vector<long long int > a(n);

    vector<long long int > b(n);
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(long long int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    if(n==2)
    {
        if(a[0]!=b[0] || a[1]!=b[1])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    for(long long int i=n-1;i>0;i--)
    {

        a[i]=a[i]-a[i-1];
    }

    for(long long int i=n-1;i>0;i--)
    {
        b[i]=b[i]-b[i-1];
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    for(long long int i=0;i<n;i++)
    {
        if(a[i]!=b[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    vector<long long int > a(n);
    vector<long long int > diffa;
    vector<long long int > diffb;
    vector<long long int > b(n);
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
        if(i!=0)
        {
            diffa.push_back(a[i]-a[i-1]);

        }
    }
    for(long long int i=0;i<n;i++)
    {
        cin>>b[i];
         if(i!=0)
        {
            diffb.push_back(b[i]-b[i-1]);
        }
    }
    if(n==2)
    {
        if(a[0]!=b[0] || a[1]!=b[1])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }

    sort(diffa.begin(),diffa.end());
    sort(diffb.begin(),diffb.end());
    diffa.push_back(a[0]);
    diffb.push_back(b[0]);

    if(diffa==diffb)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;

    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    vector<long long int > a(n);
    vector<long long int > diffa;
    vector<long long int > diffb;
    vector<long long int > b(n);
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
        if(i!=0)
        {
            diffa.push_back(a[i]-a[i-1]);

        }
    }
    for(long long int i=0;i<n;i++)
    {
        cin>>b[i];
         if(i!=0)
        {
            diffb.push_back(b[i]-b[i-1]);
        }
    }
    if(n==2)
    {
        if(a[0]!=b[0] || a[1]!=b[1])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }

    sort(diffa.begin(),diffa.end());
    sort(diffb.begin(),diffb.end());
    diffa.push_back(a[0]);
    diffb.push_back(b[0]);
    for(int i=0;i<n;i++)
    {
        cout<<diffa[i]<<" & "<<diffb[i]<<endl;

    }
    if(diffa==diffb)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;

    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    vector<long long int > a(n);

    vector<long long int > b(n);
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(long long int i=n-1;i>0;i--)
    {

        a[i]=a[i]-a[i-1];
    }
    for(long long int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    for(long long int i=n-1;i>0;i--)
    {
        b[i]=b[i]-b[i-1];
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    for(long long int i=0;i<n;i++)
    {
        if(a[i]!=b[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    vector<long long int > a(n);

    vector<long long int > b(n);
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(long long int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    if(n==2)
    {
        if(a[0]!=b[0] || a[1]!=b]1])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    for(long long int i=n-1;i>0;i--)
    {

        a[i]=a[i]-a[i-1];
    }

    for(long long int i=n-1;i>0;i--)
    {
        b[i]=b[i]-b[i-1];
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    for(long long int i=0;i<n;i++)
    {
        if(a[i]!=b[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

ll mp[1000005],n,m,x,ans,t,dp[1000005][3][3];

int main()
{
	cin>>n;
	ll a[n],b[n],i;
	set<ll> s1,s2;

	for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<n;i++) cin>>b[i];
	//dp1[0]=abs(a[0]),dp2[0]=abs(b[0]);
//	s1.insert(a[0]);s2.insert(b[0]);
//		s1.insert(a[n-1]);s2.insert(b[n-1]);
	for(i=1;i<n;i++){ s1.insert((a[i]-a[i-1]));s2.insert((b[i]-b[i-1]));}
	int flg=1;
	set<ll>::iterator itr1,itr2;
//	for(itr1=s1.begin(),itr2=s2.begin();itr1!=s1.end();itr1++,itr2++) {if((*itr1)!=(*itr2)) flg=0;break;}
	if(( s1!=s2 )|| (a[0]!=b[0]) || (a[n-1]!=b[n-1])) cout<<"No";
	else cout<<"Yes";
	return 0;
}


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

ll mp[1000005],n,m,x,ans,t,dp[1000005][3][3];

int main()
{
	cin>>n;
	ll a[n],b[n],i;
	set<ll> s1,s2;

	for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<n;i++) cin>>b[i];
	//dp1[0]=abs(a[0]),dp2[0]=abs(b[0]);
	s1.insert(a[0]);s2.insert(b[0]);
		s1.insert(a[n-1]);s2.insert(b[n-1]);
	for(i=1;i<n;i++){ s1.insert(abs(a[i]-a[i-1]));s2.insert(abs(b[i]-b[i-1]));}
	int flg=1;
	set<ll>::iterator itr1,itr2;
	for(itr1=s1.begin(),itr2=s2.begin();itr1!=s1.end();itr1++,itr2++) {if((*itr1)!=(*itr2)) flg=0;break;}
	if(flg) cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

ll mp[1000005],n,m,x,ans,t,dp[1000005][3][3];

int main()
{
	cin>>n;
	ll a[n],b[n],i;
	set<ll> s1,s2;

	for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<n;i++) cin>>b[i];
	//dp1[0]=abs(a[0]),dp2[0]=abs(b[0]);
	s1.insert(a[0]);s2.insert(b[0]);
	for(i=1;i<n;i++){ s1.insert(abs(a[i]-a[i-1]));s2.insert(abs(b[i]-b[i-1]));}
	int flg=1;
	set<ll>::iterator itr1,itr2;
	for(itr1=s1.begin(),itr2=s2.begin();itr1!=s1.end();itr1++,itr2++) {if((*itr1)!=(*itr2)) flg=0;break;}
	if(flg) cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

ll mp[1000005],n,m,x,ans,t,dp[1000005][3][3];

int main()
{
	cin>>n;
	ll a[n],b[n],i;
	multiset<ll> s1,s2;

	for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<n;i++) cin>>b[i];
	//dp1[0]=abs(a[0]),dp2[0]=abs(b[0]);
//	s1.insert(a[0]);s2.insert(b[0]);
//		s1.insert(a[n-1]);s2.insert(b[n-1]);
	for(i=1;i<n;i++){ s1.insert((a[i]-a[i-1]));s2.insert((b[i]-b[i-1]));}
	int flg=1;
	set<ll>::iterator itr1,itr2;
//	for(itr1=s1.begin(),itr2=s2.begin();itr1!=s1.end();itr1++,itr2++) {if((*itr1)!=(*itr2)) flg=0;break;}
	if(( s1!=s2 )|| (a[0]!=b[0]) || (a[n-1]!=b[n-1])) cout<<"No";
	else cout<<"Yes";
	return 0;
}


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

ll mp[1000005],n,m,x,ans,t,dp[1000005][3][3];

int main()
{
	cin>>n;
	ll a[n],b[n],i;
	set<ll> s1,s2;

	for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<n;i++) cin>>b[i];
	//dp1[0]=abs(a[0]),dp2[0]=abs(b[0]);
//	s1.insert(a[0]);s2.insert(b[0]);
	for(i=1;i<n;i++){ s1.insert(abs(a[i]-a[i-1]));s2.insert(abs(b[i]-b[i-1]));}
	int flg=1;
	set<ll>::iterator itr1,itr2;
	for(itr1=s1.begin(),itr2=s2.begin();itr1!=s1.end();itr1++,itr2++) {if((*itr1)!=(*itr2)) flg=0;break;}
	if(flg) cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

ll mp[1000005],n,m,x,ans,t,dp[1000005][3][3];

int main()
{
	cin>>n;
	ll a[n],b[n],i;
	set<ll> s1,s2;

	for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<n;i++) cin>>b[i];
	//dp1[0]=abs(a[0]),dp2[0]=abs(b[0]);
//	s1.insert(a[0]);s2.insert(b[0]);
//		s1.insert(a[n-1]);s2.insert(b[n-1]);
	for(i=1;i<n;i++){ s1.insert(abs(a[i]-a[i-1]));s2.insert(abs(b[i]-b[i-1]));}
	int flg=1;
	set<ll>::iterator itr1,itr2;
	for(itr1=s1.begin(),itr2=s2.begin();itr1!=s1.end();itr1++,itr2++) {if((*itr1)!=(*itr2)) flg=0;break;}
	if(!flg || a[0]!=b[0] || a[n-1]!=b[n-1]) cout<<"No";
	else cout<<"Yes";
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

const int N=100005;

int n,a[N],b[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]);
	for (int i=n;i>1;i--) a[i]-=a[i-1],b[i]-=b[i-1];
	std::sort(a+1,a+n+1);std::sort(b+1,b+n+1);
	for (int i=2;i<=n;i++)
		if (a[i]!=b[i]) {puts("No");return 0;}
	puts("Yes");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

const int N=100005;

int n,a[N],b[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]);
	for (int i=n;i>1;i--) a[i]-=a[i-1],b[i]-=b[i-1];
	std::sort(a+2,a+n+1);std::sort(b+2,b+n+1);
	for (int i=2;i<=n;i++)
		if (a[i]!=b[i]) {puts("No");return 0;}
	puts("Yes");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

const int N=100005;

int n,a[N],b[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]);
	for (int i=n;i>1;i--) a[i]-=a[i-1],b[i]-=b[i-1];
	std::sort(a+1,a+n+1);std::sort(b+1,b+n+1);
	for (int i=1;i<=n;i++)
		if (a[i]!=b[i]) {puts("No");return 0;}
	puts("Yes");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

const int N=100005;

int n,a[N],b[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 (a[1]!=b[1]||a[n]!=b[n]) {puts("No");return 0;}
	for (int i=n;i>1;i--) a[i]-=a[i-1],b[i]-=b[i-1];
	std::sort(a+1,a+n+1);std::sort(b+1,b+n+1);
	for (int i=1;i<=n;i++)
		if (a[i]!=b[i]) {puts("No");return 0;}
	puts("Yes");
	return 0;
}


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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    int n; cin >> n;
    vector<int> a(n), b(n), d1(n), d2(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i) d1[i - 1] = a[i] - a[i - 1];
    } d1[n - 1] = a[0];
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        if (i) d2[i - 1] = b[i] - b[i - 1];
    } d2[n - 1] = b[0];
    sort(d1.begin(), d1.end());
    sort(d2.begin(), d2.end());
    for (int i = 0; i < n; i++) {
        if (d1[i] != d2[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    cerr << "TIME => " << now() - start << endl;
    return 0;
}


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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    int n; cin >> n;
    vector<int> a(n), b(n), d1(n - 1), d2(n - 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i) d1[i - 1] = a[i] - a[i - 1];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        if (i) d2[i - 1] = b[i] - b[i - 1];
    }
    sort(d1.begin(), d1.end());
    sort(d2.begin(), d2.end());
    for (int i = 0; i < n - 1; i++) {
        if (d1[i] != d2[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    if (a[0] == b[0]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    cerr << "TIME => " << now() - start << endl;
    return 0;
}


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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    int n; cin >> n;
    vector<int> a(n), b(n), d1(n - 1), d2(n - 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i) d1[i - 1] = a[i] - a[i - 1];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        if (i) d2[i - 1] = b[i] - b[i - 1];
    }
    sort(d1.begin(), d1.end());
    sort(d2.begin(), d2.end());
    for (int i = 0; i < n; i++) {
        if (d1[i] != d2[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    if (a[0] == b[0]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    cerr << "TIME => " << now() - start << endl;
    return 0;
}


#include <bits/stdc++.h>
#define ll int
#define ld long double
#define inf 3000000000000000000
#define maxn 100010
#define MOD 998244353
#define fre freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pb push_back
#define logmax 25
#define pll pair<ll,ll>
#define PRE ' '<<fixed<<setprecision(1)<<' '
#define vi vector<ll>
#define vvi vector<vector<ll> >
#define vii vector<pll>
#define vvpll vector<vector<pll> >
#define vpll vector<pll>
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) (ll)((v).size())

using namespace std;

ll n,c[maxn],t[maxn];

bool solve(ll l,ll r)
{
	// cout<<l<<' '<<r<<'\n';
	while(l<=r)
	{
		cout<<l<<' '<<r<<'\n';
		bool ok=1;
		if(c[l+1]+c[l-1]-c[l]==t[l])
		{
			c[l]=t[l];
			ok=0;
			l++;
		}
		if(c[r+1]+c[r-1]-c[r]==t[r])
		{
			c[r]=t[r];
			ok=0;
			r--;
		}
		if(ok)
		{
			return 0;
		}
	}
	return 1;
}

int main()
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
	// cout.tie(NULL);
	ll tt;
	tt=1;
	// cin>>tt;
	while(tt--)
	{
		cin>>n;
		ll d1[n],d2[n];
		for(int i=0;i<n;i++)
		{
			cin>>c[i];
			if(i)
			{
				d1[i]=c[i]-c[i-1];
			}
		}
		for(int i=0;i<n;i++)
		{
			cin>>t[i];
			if(i)
			{
				d2[i]=t[i]-t[i-1];
			}
		}
		sort(d1+1,d1+n);
		sort(d2+1,d2+n);
		bool ok=1;
		for(int i=1;i<n;i++)
		{
			if(d1[i]!=d2[i])
			{
				ok=0;
				break;
			}
		}
		if(ok)
		{
			cout<<"Yes\n";
		}else
		{
			cout<<"No\n";
		}
	}
}

/*
ll gcd(ll a,ll b)
{
	while (a&&b)a>b?a%=b:b%=a;
	return a+b;
}
*/

/*
ll power(ll x,ll p,ll mod)
{
	if(p==0) return 1;
	ll ret=power(x,p/2,mod);
	ret=(ret*ret)%mod;
	if(p%2) ret=(ret*x)%mod;
	return ret;
}
*/

/*
ll modinverse(ll x,ll mod)
{
	return power(x,mod-2,mod);
}
*/

/*
template <class T>
struct fenwick {
	int sz;
	T tr[maxn];

	void init(int n) {
		sz = n + 2;
		memset(tr, 0, sizeof(tr));
	}

	T query(int idx) {
		idx += 1;
		T ans = 0;
		for(; idx >= 1; idx -= (idx & -idx))
			ans += tr[idx];
		return ans;
	}

	void update(int idx, T val) {
		idx += 1;
		if(idx <= 0) return;
		for(; idx <= sz; idx += (idx & -idx))
			tr[idx] += val;
	}

	T query(int l, int r) { return query(r) - query(l - 1); }
};
*/


#include <bits/stdc++.h>
#define ll int
#define ld long double
#define inf 3000000000000000000
#define maxn 100010
#define MOD 998244353
#define fre freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pb push_back
#define logmax 25
#define pll pair<ll,ll>
#define PRE ' '<<fixed<<setprecision(1)<<' '
#define vi vector<ll>
#define vvi vector<vector<ll> >
#define vii vector<pll>
#define vvpll vector<vector<pll> >
#define vpll vector<pll>
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) (ll)((v).size())

using namespace std;

ll n,c[maxn],t[maxn];

bool solve(ll l,ll r)
{
	// cout<<l<<' '<<r<<'\n';
	while(l<=r)
	{
		bool ok=1;
		if(c[l+1]+c[l-1]-c[l]==t[l])
		{
			c[l]=t[l];
			ok=0;
			l++;
		}
		if(c[r+1]+c[r-1]-c[r]==t[r])
		{
			c[r]=t[r];
			ok=0;
			r--;
		}
		if(ok)
		{
			return 0;
		}
	}
	return 1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll tt;
	tt=1;
	// cin>>tt;
	while(tt--)
	{
		cin>>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\n";
		}else
		{
			vpll tmp;
			ll st,en;
			for(int i=1;i<n-1;i++)
			{
				if(c[i]!=t[i])
				{
					if(st==-1)
					{
						st=i;
					}
					en=i;
				}else
				{
					if(st!=-1)
					{
						tmp.pb({st,en});
					}
					st=-1;
				}
			}
			if(st!=-1)
			{
				tmp.pb({st,en});
			}
			bool ok=1;
			for(int i=0;i<tmp.size();i++)
			{
				if(solve(tmp[i].first,tmp[i].second)==0)
				{
					ok=0;
					break;
				}
			}
			if(ok)
			{
				cout<<"Yes\n";
			}else
			{
				cout<<"No\n";
			}
		}
	}
}

/*
ll gcd(ll a,ll b)
{
	while (a&&b)a>b?a%=b:b%=a;
	return a+b;
}
*/

/*
ll power(ll x,ll p,ll mod)
{
	if(p==0) return 1;
	ll ret=power(x,p/2,mod);
	ret=(ret*ret)%mod;
	if(p%2) ret=(ret*x)%mod;
	return ret;
}
*/

/*
ll modinverse(ll x,ll mod)
{
	return power(x,mod-2,mod);
}
*/

/*
template <class T>
struct fenwick {
	int sz;
	T tr[maxn];

	void init(int n) {
		sz = n + 2;
		memset(tr, 0, sizeof(tr));
	}

	T query(int idx) {
		idx += 1;
		T ans = 0;
		for(; idx >= 1; idx -= (idx & -idx))
			ans += tr[idx];
		return ans;
	}

	void update(int idx, T val) {
		idx += 1;
		if(idx <= 0) return;
		for(; idx <= sz; idx += (idx & -idx))
			tr[idx] += val;
	}

	T query(int l, int r) { return query(r) - query(l - 1); }
};
*/


#include <bits/stdc++.h>
#define ll int
#define ld long double
#define inf 3000000000000000000
#define maxn 100010
#define MOD 998244353
#define fre freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pb push_back
#define logmax 25
#define pll pair<ll,ll>
#define PRE ' '<<fixed<<setprecision(1)<<' '
#define vi vector<ll>
#define vvi vector<vector<ll> >
#define vii vector<pll>
#define vvpll vector<vector<pll> >
#define vpll vector<pll>
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) (ll)((v).size())

using namespace std;

ll n,c[maxn],t[maxn];

bool solve(ll l,ll r)
{
	// cout<<l<<' '<<r<<'\n';
	while(l<=r)
	{
		cout<<l<<' '<<r<<'\n';
		bool ok=1;
		if(c[l+1]+c[l-1]-c[l]==t[l])
		{
			c[l]=t[l];
			ok=0;
			l++;
		}
		if(c[r+1]+c[r-1]-c[r]==t[r])
		{
			c[r]=t[r];
			ok=0;
			r--;
		}
		if(ok)
		{
			return 0;
		}
	}
	return 1;
}

int main()
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
	// cout.tie(NULL);
	ll tt;
	tt=1;
	// cin>>tt;
	while(tt--)
	{
		cin>>n;
		ll d1[n],d2[n];
		for(int i=0;i<n;i++)
		{
			cin>>c[i];
			if(i)
			{
				d1[i]=c[i]-c[i-1];
			}
		}
		for(int i=0;i<n;i++)
		{
			cin>>t[i];
			if(i)
			{
				d2[i]=t[i]-t[i-1];
			}
		}
		if(c[0]!=t[0]||c[n-1]!=t[n-1])
		{
			cout<<"No\n";
			return 0;
		}
		sort(d1+1,d1+n);
		sort(d2+1,d2+n);
		bool ok=1;
		for(int i=1;i<n;i++)
		{
			if(d1[i]!=d2[i])
			{
				ok=0;
				break;
			}
		}
		if(ok)
		{
			cout<<"Yes\n";
		}else
		{
			cout<<"No\n";
		}
	}
}

/*
ll gcd(ll a,ll b)
{
	while (a&&b)a>b?a%=b:b%=a;
	return a+b;
}
*/

/*
ll power(ll x,ll p,ll mod)
{
	if(p==0) return 1;
	ll ret=power(x,p/2,mod);
	ret=(ret*ret)%mod;
	if(p%2) ret=(ret*x)%mod;
	return ret;
}
*/

/*
ll modinverse(ll x,ll mod)
{
	return power(x,mod-2,mod);
}
*/

/*
template <class T>
struct fenwick {
	int sz;
	T tr[maxn];

	void init(int n) {
		sz = n + 2;
		memset(tr, 0, sizeof(tr));
	}

	T query(int idx) {
		idx += 1;
		T ans = 0;
		for(; idx >= 1; idx -= (idx & -idx))
			ans += tr[idx];
		return ans;
	}

	void update(int idx, T val) {
		idx += 1;
		if(idx <= 0) return;
		for(; idx <= sz; idx += (idx & -idx))
			tr[idx] += val;
	}

	T query(int l, int r) { return query(r) - query(l - 1); }
};
*/


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

int n,c[100005],t[100005];

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


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

int n,c[100005],t[100005];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",c+i);
	for(int i=1;i<=n;i++)scanf("%d",t+i);
	for(int i=n;i;i--)c[i]-=c[i-1],t[i]-=t[i-1];
	sort(c+1,c+1+n);sort(t+1,t+1+n);
	for(int i=1;i<=n;i++)if(c[i]!=t[i])return !puts("No");
	puts("Yes");
}


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

int n,c[100005],t[100005];

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


#define ll long long int
#include<bits/stdc++.h>
#define bug(n) cout<<n;return 0;
using namespace std;
int main()
{ ll n;
  cin>>n;
  vector<ll> v(n);
  vector<ll> v1(n);
  for(ll i=0;i<n;i++){cin>>v[i];}
  for(ll i=0;i<n;i++){cin>>v1[i];}
  vector<ll> d(n-1);
  vector<ll> d1(n-1);
  for(ll i=0;i<n-1;i++)
  {
      d[i]=v[i+1]-v[i];
     // cout<<"d"<<d[i]<<endl;
      d1[i]=v1[i+1]-v1[i];
    //  cout<<"d1"<<d1[i]<<endl;
  }
  sort(d.begin(),d.end());
  sort(d1.begin(),d1.end());
  int flag=1;
  for(ll i=0;i<n-1;i++)
  {  //cout<<d[i]<<d1[i]<<endl;
      if(d[i]!=d1[i])
         {
             cout<<"No";
             flag=0;
             return 0;
         }
  }
  map<ll,ll> hash;
  for(ll i=0;i<n;i++){hash[v[i]]=1;}
  for(ll i=0;i<n;i++)
  {
      if(hash.find(v1[i])!=hash.end())
         {

              cout<<"Yes";
              return 0;

         }
  }
  cout<<"No";
  return 0;

}


#define ll long long int
#include<bits/stdc++.h>
#define bug(n) cout<<n;return 0;
using namespace std;
int main()
{ ll n;
  cin>>n;
  vector<ll> v(n);
  vector<ll> v1(n);
  for(ll i=0;i<n;i++){cin>>v[i];}
  for(ll i=0;i<n;i++){cin>>v1[i];}
  vector<ll> d(n-1);
  vector<ll> d1(n-1);
  for(ll i=0;i<n-1;i++)
  {
      d[i]=v[i+1]-v[i];
     // cout<<"d"<<d[i]<<endl;
      d1[i]=v1[i+1]-v1[i];
    //  cout<<"d1"<<d1[i]<<endl;
  }
  sort(d.begin(),d.end());
  sort(d1.begin(),d1.end());
  int flag=1;
  for(ll i=0;i<n-1;i++)
  {  //cout<<d[i]<<d1[i]<<endl;
      if(d[i]!=d1[i])
         {
             cout<<"No";
             flag=0;
             return 0;
         }
  }
  map<ll,int> hash;
  for(ll i=0;i<n;i++){hash[v[i]]=1;}
  for(ll i=0;i<n;i++)
  {
      if(hash.find(v1[i])!=hash.end())
         {

              cout<<"Yes";
              return 0;

         }
  }
  cout<<"No";
  return 0;

}


#define ll long long int
#include<bits/stdc++.h>
#define bug(n) cout<<n;return 0;
using namespace std;
int main()
{ ll n;
  cin>>n;
  vector<ll> v(n);
  vector<ll> v1(n);
  for(ll i=0;i<n;i++){cin>>v[i];}
  for(ll i=0;i<n;i++){cin>>v1[i];}
  vector<ll> d(n-1);
  vector<ll> d1(n-1);
  for(ll i=0;i<n-1;i++)
  {
      d[i]=v[i+1]-v[i];
     // cout<<"d"<<d[i]<<endl;
      d1[i]=v1[i+1]-v1[i];
    //  cout<<"d1"<<d1[i]<<endl;
  }
  sort(d.begin(),d.end());
  sort(d1.begin(),d1.end());
  int flag=1;
  for(ll i=0;i<n-1;i++)
  {  //cout<<d[i]<<d1[i]<<endl;
      if(d[i]!=d1[i])
         {
             cout<<"No";
             flag=0;
             return 0;
         }
  }
  if(v[0]==v1[0])
     {
         cout<<"Yes";
         return 0;
     }
  cout<<"No";
  return 0;

}


#define ll long long int
#include<bits/stdc++.h>
#define bug(n) cout<<n;return 0;
using namespace std;
int main()
{ ll n;
  cin>>n;
  vector<ll> v(n);
  vector<ll> v1(n);
  for(ll i=0;i<n;i++){cin>>v[i];}
  for(ll i=0;i<n;i++){cin>>v1[i];}
  vector<ll> d(n-1);
  vector<ll> d1(n-1);
  for(ll i=0;i<n-1;i++)
  {
      d[i]=v[i+1]-v[i];
     // cout<<"d"<<d[i]<<endl;
      d1[i]=v1[i+1]-v1[i];
    //  cout<<"d1"<<d1[i]<<endl;
  }
  sort(d.begin(),d.end());
  sort(d1.begin(),d1.end());
  int flag=1;
  for(ll i=0;i<n-1;i++)
  {  //cout<<d[i]<<d1[i]<<endl;
      if(d[i]!=d1[i])
         {
             cout<<"No";
             flag=0;
             return 0;
         }
  }
  if(v[i]==v1[i])
     {
         cout<<"Yes";
         return 0;
     }
  cout<<"No";
  return 0;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
int a[maxn], b[maxn];
int c[maxn], d[maxn];
int main(){
	int n;
	cin >> 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++){
		c[i - 1] = b[i] - b[i - 1];
		d[i - 1] = a[i] - a[i - 1];
	}
	sort(c + 1, c + 1 + n);
	sort(d + 1, d + 1 + n);
	int flag = 0;
	for (int i = 1; i <= n; i++){
		if (c[i] != d[i]){
			flag = 1;
			break;
		}
	}
	if (flag) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
int a[maxn], b[maxn];
ll c[maxn], d[maxn];
int main(){
	int n;
	cin >> 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++){
		c[i - 1] = b[i] - b[i - 1];
		d[i - 1] = a[i] - a[i - 1];
	}
	sort(c + 1, c + 1 + n);
	sort(d + 1, d + 1 + n);
	int flag = 0;
	for (int i = 1; i <= n; i++){
		if (c[i] != d[i]){
			flag = 1;
			break;
		}
	}
	if (flag) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
ll a[maxn], b[maxn];
ll c[maxn], d[maxn];
int main(){
	int n;
	cin >> 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++){
		c[i - 1] = b[i] - b[i - 1];
		d[i - 1] = a[i] - a[i - 1];
	}
	sort(c + 1, c + 1 + n);
	sort(d + 1, d + 1 + n);
	int flag = 0;
	for (int i = 1; i <= n; i++){
		if (c[i] != d[i]){
			flag = 1;
			break;
		}
	}
	if (flag) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
ll a[maxn], b[maxn];
ll c[maxn], d[maxn];
int main(){
	int n;

	cin >> n;
	for (int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	for (int i = 1; i <= n; i++)
		scanf("%lld", &b[i]);
	for (int i = 2; i <= n; i++){
		c[i - 1] = b[i] - b[i - 1];
		d[i - 1] = a[i] - a[i - 1];
	}
	sort(c + 1, c + 1 + n);
	sort(d + 1, d + 1 + n);
	if (a[1] != b[1] || a[n] != b[n])
		cout << "No" << endl, exit(0);
	int flag = 0;
	for (int i = 1; i <= n; i++){
		if (c[i] != d[i]){
			flag = 1;
			break;
		}
	}
	if (flag) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>

#define int long long

std::vector<std::vector<int> > v;

int calc(int m, int i) {
  return v[m][i+1] + v[m][i-1] - v[m][i];
}

signed main() {
  int n;
  std::cin >> n;

  v = std::vector<std::vector<int> >(2, std::vector<int>(n));
  for(int i = 0; i < 2; i++)
    for(int j = 0; j < n; j++)
      std::cin >> v[i][j];

  for(int m = 0; m < 2; m++) {
    for(int i = n-1; i > 0; i--)
      v[m][i] -= v[m][i-1];

    std::sort(v[m].begin() + 1, v[m].end());
  }

  if(v[0] == v[1])
    std::cout << "Yes";
  else
    std::cout << "No";

  std::cout << std::endl;

  return 0;
}


#include <iostream>
#include <set>
#include <vector>

#define int long long

std::vector<std::vector<int> > v;

int calc(int m, int i) {
  return v[m][i+1] + v[m][i-1] - v[m][i];
}

signed main() {
  int n;
  std::cin >> n;

  v = std::vector<std::vector<int> >(2, std::vector<int>(n));
  for(int i = 0; i < 2; i++)
    for(int j = 0; j < n; j++)
      std::cin >> v[i][j];

  for(int m = 0; m < 2; m++) {
    std::set<std::pair<int, int> > s;
    for(int i = 1; i+1 < n; i++)
      s.insert({v[m][i] - calc(m, i), i});

    int count = 0;
    while(true) {
      std::pair<int, int> cur = *s.begin(); s.erase(s.begin());
      int u = cur.second;

      if(cur.first >= 0)
        break;

      int nval = calc(m, u);

      if(u > 1)
        s.erase({v[m][u-1] - calc(m, u-1), u-1});
      if(u+2 < n)
        s.erase({v[m][u+1] - calc(m, u+1), u+1});

      v[m][u] = nval;

      for(int i = std::max(1ll, u-1); i <= std::min(n-2, u+1); i++)
        s.insert({v[m][i] - calc(m, i), i});

      count++;
      if(count > 200000) {
        if(v[0][0] == v[1][0] && v[0][n-1] == v[1][n-1])
          std::cout << "Yes" << std::endl;
        else
          std::cout << "No" << std::endl;
        return 0;
      }
    }
  }

  if(v[0] == v[1])
    std::cout << "Yes";
  else
    std::cout << "No";

  std::cout << std::endl;

  return 0;
}


#include <iostream>
#include <set>
#include <vector>

#define int long long

std::vector<std::vector<int> > v;

int calc(int m, int i) {
  return v[m][i+1] + v[m][i-1] - v[m][i];
}

signed main() {
  int n;
  std::cin >> n;

  v = std::vector<std::vector<int> >(2, std::vector<int>(n));
  for(int i = 0; i < 2; i++)
    for(int j = 0; j < n; j++)
      std::cin >> v[i][j];

  for(int m = 0; m < 2; m++) {
    std::set<std::pair<int, int> > s;
    for(int i = 1; i+1 < n; i++)
      s.insert({v[m][i] - calc(m, i), i});

    int count = 0;
    while(true) {
      std::pair<int, int> cur = *s.begin(); s.erase(s.begin());
      int u = cur.second;

      if(cur.first >= 0)
        break;

      int nval = calc(m, u);

      if(u > 1)
        s.erase({v[m][u-1] - calc(m, u-1), u-1});
      if(u+2 < n)
        s.erase({v[m][u+1] - calc(m, u+1), u+1});

      v[m][u] = nval;

      for(int i = std::max(1ll, u-1); i <= std::min(n-2, u+1); i++)
        s.insert({v[m][i] - calc(m, i), i});

      if(count > 3000000) {
        if(v[0][0] == v[1][0] && v[0][n-1] == v[1][n-1])
          std::cout << "Yes" << std::endl;
        else
          std::cout << "No" << std::endl;
        return 0;
      }
    }
  }

  if(v[0] == v[1])
    std::cout << "Yes";
  else
    std::cout << "No";

  std::cout << std::endl;

  return 0;
}


#include <iostream>
#include <set>
#include <vector>

#define int long long

std::vector<std::vector<int> > v;

int calc(int m, int i) {
  return v[m][i+1] + v[m][i-1] - v[m][i];
}

signed main() {
  int n;
  std::cin >> n;

  v = std::vector<std::vector<int> >(2, std::vector<int>(n));
  for(int i = 0; i < 2; i++)
    for(int j = 0; j < n; j++)
      std::cin >> v[i][j];

  for(int m = 0; m < 2; m++) {
    std::set<std::pair<int, int> > s;
    for(int i = 1; i+1 < n; i++)
      s.insert({v[m][i] - calc(m, i), i});

    while(true) {
      std::pair<int, int> cur = *s.begin(); s.erase(s.begin());
      int u = cur.second;

      if(cur.first >= 0)
        break;

      int nval = calc(m, u);

      if(u > 1)
        s.erase({v[m][u-1] - calc(m, u-1), u-1});
      if(u+2 < n)
        s.erase({v[m][u+1] - calc(m, u+1), u+1});

      v[m][u] = nval;

      for(int i = std::max(1ll, u-1); i <= std::min(n-2, u+1); i++)
        s.insert({v[m][i] - calc(m, i), i});
    }
  }

  if(v[0] == v[1])
    std::cout << "Yes";
  else
    std::cout << "No";

  std::cout << std::endl;

  return 0;
}


#include <iostream>
#include <set>
#include <vector>

#define int long long

std::vector<std::vector<int> > v;

int calc(int m, int i) {
  return v[m][i+1] + v[m][i-1] - v[m][i];
}

signed main() {
  int n;
  std::cin >> n;

  v = std::vector<std::vector<int> >(2, std::vector<int>(n));
  for(int i = 0; i < 2; i++)
    for(int j = 0; j < n; j++)
      std::cin >> v[i][j];

  for(int m = 0; m < 2; m++) {
    std::set<std::pair<int, int> > s;
    for(int i = 1; i+1 < n; i++)
      s.insert({v[m][i] - calc(m, i), i});

    int count = 0;
    while(true) {
      std::pair<int, int> cur = *s.begin(); s.erase(s.begin());
      int u = cur.second;

      if(cur.first >= 0)
        break;

      int nval = calc(m, u);

      if(u > 1)
        s.erase({v[m][u-1] - calc(m, u-1), u-1});
      if(u+2 < n)
        s.erase({v[m][u+1] - calc(m, u+1), u+1});

      v[m][u] = nval;

      for(int i = std::max(1ll, u-1); i <= std::min(n-2, u+1); i++)
        s.insert({v[m][i] - calc(m, i), i});

      count++;
      if(count > 3000000) {
        if(v[0][0] == v[1][0] && v[0][n-1] == v[1][n-1])
          std::cout << "Yes" << std::endl;
        else
          std::cout << "No" << std::endl;
        return 0;
      }
    }
  }

  if(v[0] == v[1])
    std::cout << "Yes";
  else
    std::cout << "No";

  std::cout << std::endl;

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define pb push_back
#define inf 1e15
#define en '\n'
#define ld long double
#define ff first
#define ss second
#define ull unsigned long long
#define lb lower_bound
#define ub upper_bound
#define fr(a,b,c) for(ll a = b ; a <= c ; ++a )
#define frn(a,b,c) for(ll a = b ; a >= c ; a -- )
#define fra(a,b) for(auto a: b)
#define ms(a) memset(a,0,sizeof a);
#define alla(a) a,a+n
#define allv(a) a.begin(),a.end()
#define size(a) (ll)a.size()
#define getMat(x,n,m,val) vector<vector<ll>>x(n,vector<ll>(m,val))
const ll MAXN = 1e5+5;
#define pii 3.14159265358979323846
const ll mod = 1e9+7;
ll n;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	ll arr[n];fr(i,0,n-1)cin>>arr[i];
	ll t[n];fr(i,0,n-1)cin>>t[i];
	fr(i,1,n-2){
		if(arr[i]==t[i])continue;
		// cout<<": "<<t[i+1]<<" "<<t[i-1]<<" "<<t[i]<<" "<<arr[i]<<en;
		if(t[i+1]+t[i-1]-t[i]==arr[i]){
			// cout<<"yes"<<en;
			t[i]=arr[i];
			ll curr =  i-1;
			while(curr>=1){
				if(arr[curr]==t[curr])break;
				if(t[curr+1]+t[curr-1]-t[curr]==arr[curr]){
					t[curr]=arr[curr];
					curr--;
				} else break;
			}
		}
	}
	bool flag = true;
	fr(i,0,n-1){
		if(arr[i]!=t[i]){
			flag = false;
			break;
		}
	}
	if(flag)cout<<"Yes"<<en;
	else  cout<<"No"<<en;
	return 0 ;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define pb push_back
#define inf 1e15
#define en '\n'
#define ld long double
#define ff first
#define ss second
#define ull unsigned long long
#define lb lower_bound
#define ub upper_bound
#define fr(a,b,c) for(ll a = b ; a <= c ; ++a )
#define frn(a,b,c) for(ll a = b ; a >= c ; a -- )
#define fra(a,b) for(auto a: b)
#define ms(a) memset(a,0,sizeof a);
#define alla(a) a,a+n
#define allv(a) a.begin(),a.end()
#define size(a) (ll)a.size()
#define getMat(x,n,m,val) vector<vector<ll>>x(n,vector<ll>(m,val))
const ll MAXN = 1e5+5;
#define pii 3.14159265358979323846
const ll mod = 1e9+7;
ll n;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	ll arr[n];fr(i,0,n-1)cin>>arr[i];
	ll t[n];fr(i,0,n-1)cin>>t[i];
	fr(i,1,n-2){
		if(arr[i]==t[i])continue;
		if(t[i+1]+t[i-1]-t[i]==arr[i]){
			t[i]=arr[i];
			ll curr =  i-1;
			while(curr>=1){
				if(arr[curr]==t[curr])break;
				if(t[curr+1]+t[curr-1]==arr[curr]){
					t[curr]=arr[curr];
					curr--;
				} else break;
			}
		}
	}
	bool flag = true;
	fr(i,0,n-1){
		if(arr[i]!=t[i]){
			flag = false;
			break;
		}
	}
	if(flag)cout<<"Yes"<<en;
	else  cout<<"No"<<en;
	return 0 ;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define pb push_back
#define inf 1e15
#define en '\n'
#define ld long double
#define ff first
#define ss second
#define ull unsigned long long
#define lb lower_bound
#define ub upper_bound
#define fr(a,b,c) for(ll a = b ; a <= c ; ++a )
#define frn(a,b,c) for(ll a = b ; a >= c ; a -- )
#define fra(a,b) for(auto a: b)
#define ms(a) memset(a,0,sizeof a);
#define alla(a) a,a+n
#define allv(a) a.begin(),a.end()
#define size(a) (ll)a.size()
#define getMat(x,n,m,val) vector<vector<ll>>x(n,vector<ll>(m,val))
const ll MAXN = 1e5+5;
#define pii 3.14159265358979323846
const ll mod = 1e9+7;
ll n;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	ll arr[n];fr(i,0,n-1)cin>>arr[i];
	ll t[n];fr(i,0,n-1)cin>>t[i];
	fr(i,1,n-2){
		if(arr[i]==t[i])continue;
		if(t[i+1]+t[i-1]-t[i]==arr[i]){
			t[i]=arr[i];
			ll curr =  i-1;
			while(curr>1){
				if(arr[curr]==t[curr])break;
				if(t[curr+1]+t[curr-1]==arr[curr]){
					t[curr]=arr[curr];
					curr--;
				} else break;
			}
		}
	}
	bool flag = true;
	fr(i,0,n-1){
		if(arr[i]!=t[i]){
			flag = false;
			break;
		}
	}
	if(flag)cout<<"Yes"<<en;
	else  cout<<"No"<<en;
	return 0 ;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define pb push_back
#define inf 1e16
#define mod 998244353
#define en '\n'
#define ld long double
#define ff first
#define ss second
#define ull unsigned long long
#define fr(a,b,c) for(int a = b ; a <= c ; a ++ )
const ll MAXN = 200010;
ll pw(ll b, ll r, ll md){
	ll ans = 1;
	while(r){
		if(r&1)ans = (ans*b)%md;
		b = (b*b)%md;
		r>>=1;
	}
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;cin>>n;
	ll arr[n];
	vector<ll>diff1,diff2;
	fr(i,0,n-1)cin>>arr[i];
	fr(i,1,n-1)diff1.pb(arr[i]-arr[i-1]);
	sort(diff1.begin(),diff1.end());
	ll val = arr[0];
	fr(i,0,n-1)cin>>arr[i];
	if(val!=arr[0]){
		cout<<"No\n";
		return 0;
	}
	fr(i,1,n-1)diff2.pb(arr[i]-arr[i-1]);
	sort(diff2.begin(),diff2.end());
	fr(i,0,n-2){
		if(diff1[i]!=diff2[i]){
			cout<<"No\n";
			break;
		}
		if(i==n-2)cout<<"Yes\n";
	}
	return 0 ;
}


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

#define ll long int

vector <ll> ar1,ar2,ar3,ar4;

int main() {
	// your code goes here
ll n,i,a;
cin>>n;
for(i=0;i<n;i++)
 {
    cin>>a;
    ar1.push_back(a);
 }
for(i=0;i<n-1;i++)
 {
    ar3.push_back(ar1[i+1]-ar1[i]);
 }
for(i=0;i<n;i++)
 {
    cin>>a;
    ar2.push_back(a);
 }
for(i=0;i<n-1;i++)
 {
    ar4.push_back(ar2[i+1]-ar2[i]);
 }
sort(ar3.begin(),ar3.end());
sort(ar4.begin(),ar4.end());
ll f=0;
if((ar1[0]!=ar2[0])||(ar1[n-1]!=ar2[n-1]))
 {
  f=1;
 }
 else
 {
for(i=0;i<n-1;i++)
 {
     if(ar3[i]!=ar4[i])
      {
          f=1;
          break;
      }
 }
 }
if(f)
 {
     cout<<"No";
 }
 else
  {
      cout<<"Yes";
  }

	return 0;
}


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

#define ll long int

vector <ll> ar1,ar2,ar3,ar4;

int main() {
	// your code goes here
ll n,i,a;
cin>>n;
for(i=0;i<n;i++)
 {
    cin>>a;
    ar1.push_back(a);
 }
for(i=0;i<n-1;i++)
 {
    ar3.push_back(ar1[i+1]-ar1[i]);
 }
for(i=0;i<n;i++)
 {
    cin>>a;
    ar2.push_back(a);
 }
for(i=0;i<n-1;i++)
 {
    ar4.push_back(ar2[i+1]-ar2[i]);
 }
sort(ar3.begin(),ar3.end());
sort(ar4.begin(),ar4.end());
ll f=0;
for(i=0;i<n-1;i++)
 {
     if(ar3[i]!=ar4[i])
      {
          f=1;
          break;
      }
 }
if(f)
 {
     cout<<"No";
 }
 else
  {
      cout<<"Yes";
  }

	return 0;
}


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

#define ll long int

vector <ll> ar1,ar2,ar3,ar4;

int main() {
	// your code goes here
ll n,i,a;
cin>>n;
for(i=0;i<n;i++)
 {
    cin>>a;
    ar1.push_back(a);
 }
for(i=0;i<n-1;i++)
 {
    ar3.push_back(ar1[i+1]-ar1[i]);
 }
for(i=0;i<n;i++)
 {
    cin>>a;
    ar2.push_back(a);
 }
for(i=0;i<n-1;i++)
 {
    ar4.push_back(ar2[i+1]-ar2[i]);
 }
sort(ar3.begin(),ar3.end());
sort(ar4.begin(),ar4.end());
ll f=0;
for(i=0;i<n;i++)
 {
     if(ar3[i]!=ar4[i])
      {
          f=1;
          break;
      }
 }
if(f)
 {
     cout<<"No";
 }
 else
  {
      cout<<"Yes";
  }

	return 0;
}


#include<bits/stdc++.h>

//#include "rubo.h"
//#define mp make_pair
//#define pb push_back
#define in int
#define ll long long
#define ull long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

#define db(x) cout << #x << " = " << x << endl
#define dbCont(x) cout << #x << ": "; for(auto shun: x) cout << shun << '\t'; cout << endl;

typedef long double ld;

using namespace std;

const int INF = 1e9 + 3;
const int N = 300 * 1000 + 5;

int solve(vector<int> &t) {

    int mn = t[0] - 1;
    for (int &e : t) {
        e -= mn;
    }

    vector<int> cnt(t.back(), 0);
    for (int e : t) {
        cnt[e - 1]++;
    }

    dbCont(cnt);

    int res = 0;
//
//    for(int i = 0; i < cnt.size(); i++){
//        res += cnt[i] / 3;
//        cnt[i] %= 3;
//
//        while(i+2 < cnt.size() && cnt[i] > 0 && cnt[i+1] > 0 && cnt[i+2] > 0){
//            cnt[i]--;
//            cnt[i+1]--;
//            cnt[i+2]--;
//            res++;
//        }
//    }
//

    t.clear();

    return res;
}

void doit(vector<int> &v, int i) {
    v[i] = v[i + 1] + v[i - 1] - v[i];
}

ll x[N], y[N];

int main() {
    ll ankap;
    cin >> ankap;
    loop(i, ankap)cin >> x[i];
    loop(i, ankap) {
        cin >> y[i];

    }
    for (ll i = 1; i <= ankap - 2; i++)
        if (x[i] != y[i]) {
            ll haj = x[i] + y[i] - x[i - 1] ;

            if ( y[i + 1] != haj ) {
                printf("No\n");
                exit(0);
            }
        }

    printf("Yes\n");
    return 0;
}

/*
Tests

 */


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

vector<int> read(int n) {
    vector<int> a(n);
    vector<int> diff;
    for(int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        if(i != 0) {
            diff.push_back(a[i] - a[i-1]);
        }
    }
    sort(diff.begin(), diff.end());
    for(int &e: diff) e ^= a[0];
    // diff.push_back(a[0]);
    return diff;
}

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a = read(n);
    vector<int> b = read(n);
    puts(a == b ? "Yes" : "No");
}


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

vector<int> read(int n) {
    vector<int> a(n);
    vector<int> diff;
    for(int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        if(i != 0) {
            diff.push_back(a[i] - a[i-1]);
        }
    }
    sort(diff.begin(), diff.end());
    for(int &e: diff) e -= a[0];
    // diff.push_back(a[0]);
    return diff;
}

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a = read(n);
    vector<int> b = read(n);
    puts(a == b ? "Yes" : "No");
}


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

vector<int> read(int n) {
    vector<int> a(n);
    vector<int> diff;
    for(int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        if(i != 0) {
            diff.push_back(a[i] - a[i-1]);
        }
    }
    sort(diff.begin(), diff.end());
    for(int &e: diff) e += a[0];
    // diff.push_back(a[0]);
    return diff;
}

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a = read(n);
    vector<int> b = read(n);
    puts(a == b ? "Yes" : "No");
}


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

vector<int> read(int n) {
    vector<int> a(n);
    vector<int> diff;
    for(int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        if(i != 0) {
            diff.push_back(a[i] - a[i-1]);
        }
    }
    sort(diff.begin(), diff.end());
    for(int &e: diff) e *= a[0]*a[0];
    // diff.push_back(a[0]);
    return diff;
}

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a = read(n);
    vector<int> b = read(n);
    puts(a == b ? "Yes" : "No");
}


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

#define rep(i, j, k) for(int i = (j); i <= (k); ++i)
#define per(i, j, k) for(int i = (j); i >= (k); --i)
#define pb push_back
const int mxn=1e6+6;
int n,a[mxn],b[mxn],c[mxn],d[mxn];
signed main(){
	scanf("%d",&n);
	rep(i,1,n)scanf("%d",a+i);
	rep(i,2,n)c[i]=a[i]-a[i-1];
	rep(i,1,n)scanf("%d",b+i);
	rep(i,2,n)d[i]=b[i]-b[i-1];
	sort(c+2,c+1+n),sort(d+2,d+1+n);
	int ok=1;
	rep(i,2,n)ok=ok&&(d[i]==c[i]);
	puts(ok&&(a[1]==b[1])?"Yes":"No");
	return 0;
}


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

#define rep(i, j, k) for(int i = (j); i <= (k); ++i)
#define per(i, j, k) for(int i = (j); i >= (k); --i)
#define pb push_back
const int mxn=1e6+6;
int n,a[mxn],b[mxn],c[mxn],d[mxn];
signed main(){
scanf("%d",&n);
rep(i,1,n)scanf("%d",a+i);
rep(i,1,n)c[i]=a[i]-a[i-1];
rep(i,1,n)scanf("%d",b+i);
rep(i,1,n)d[i]=b[i]-b[i-1];
sort(c+1,c+1+n),sort(d+1,d+1+n);
int ok=1;
rep(i,1,n)ok=ok&&(d[i]==c[i]);
puts(ok?"Yes":"No");
return 0;
}


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

#define rep(i, j, k) for(int i = (j); i <= (k); ++i)
#define per(i, j, k) for(int i = (j); i >= (k); --i)
#define pb push_back
const int mxn=1e6+6;
int n,a[mxn],b[mxn],c[mxn],d[mxn];
signed main(){
	scanf("%d",&n);
	rep(i,1,n)scanf("%d",a+i);
	rep(i,2,n)c[i]=a[i]-a[i-1];
	rep(i,1,n)scanf("%d",b+i);
	rep(i,2,n)d[i]=b[i]-b[i-1];
	sort(c+2,c+1+n),sort(d+2,d+1+n);
	int ok=1;
	rep(i,2,n)ok=ok&&(d[i]==c[i]);
	puts(ok&&(a[i]==b[i])?"Yes":"No");
	return 0;
}


#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "bitset"
#include "queue"
using namespace std;
#define MAXN 200006
#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
#define P 1000000007
typedef long long ll;
int n , m , k , blo;
int c[MAXN];
multiset<int> S[2];
void solve() {
    cin >> n;
    rep( i , 1 , n ) scanf("%lld",c + i);
    rep( i , 1 , n - 1 ) c[i] = c[i + 1] - c[i] , S[i & 1].insert( c[i] );
    rep( i , 1 , n ) scanf("%lld",c + i);
    rep( i , 1 , n - 1 ) {
        c[i] = c[i + 1] - c[i];
        if( S[i & 1].count( c[i] ) ) S[i & 1].erase( S[i&1].find(c[i]) );
        else if( S[~i & 1].count( -c[i] ) ) S[~i & 1].erase( S[~i&1].find(c[i]) );
        else return void( puts("No") );
    }
    puts("Yes");
}

signed main() {
//    freopen("input","r",stdin);
//    freopen("fuckout","w",stdout);
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "bitset"
#include "queue"
using namespace std;
#define MAXN 200006
#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
#define P 1000000007
typedef long long ll;
int n , m , k , blo;
int c[MAXN];
vi q , t; int qwq;
void solve() {
    cin >> n;
    rep( i , 1 , n ) scanf("%lld",c + i); qwq = c[1];
    rep( i , 1 , n - 1 ) c[i] = c[i + 1] - c[i] , q.pb( c[i] );
    rep( i , 1 , n ) scanf("%lld",c + i);
    if( c[1] != qwq ) return void( puts("No") );
    rep( i , 1 , n - 1 ) c[i] = c[i + 1] - c[i] , t.pb( c[i] );
    sort( all( q ) ) , sort( all( t ) );
    rep( i , 0 , n - 2 ) if( q[i] != t[i] ) return void( puts("No") );
    puts("Yes");
}

signed main() {
//    freopen("input","r",stdin);
//    freopen("fuckout","w",stdout);
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "bitset"
#include "queue"
using namespace std;
#define MAXN 200006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
#define P 1000000007
typedef long long ll;
int n , m , k , blo;
int c[MAXN];
vi q , t;
void solve() {
    cin >> n;
    rep( i , 1 , n ) scanf("%d",c + i);
    rep( i , 1 , n - 1 ) c[i] = c[i + 1] - c[i] , q.pb( c[i] );
    rep( i , 1 , n ) scanf("%d",c + i);
    rep( i , 1 , n - 1 ) c[i] = c[i + 1] - c[i] , t.pb( c[i] );
    sort( all( q ) ) , sort( all( t ) );
    rep( i , 0 , n - 2 ) if( q[i] != t[i] ) return void( puts("No") );
    puts("Yes");
}

signed main() {
//    freopen("input","r",stdin);
//    freopen("fuckout","w",stdout);
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "bitset"
#include "queue"
using namespace std;
#define MAXN 200006
#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
#define P 1000000007
typedef long long ll;
int n , m , k , blo;
int c[MAXN];
multiset<int> S[2];
void solve() {
    cin >> n;
    rep( i , 1 , n ) scanf("%lld",c + i);
    rep( i , 1 , n - 1 ) c[i] = c[i + 1] - c[i] , S[i & 1].insert( c[i] );
    rep( i , 1 , n ) scanf("%lld",c + i);
    rep( i , 1 , n - 1 ) {
        c[i] = c[i + 1] - c[i];
        if( S[i & 1].count( c[i] ) ) S[i & 1].erase( S[i&1].find(c[i]) );
        else if( S[~i & 1].count( c[i] ) ) S[~i & 1].erase( S[~i&1].find(c[i]) );
        else return void( puts("No") );
    }
    puts("Yes");
}

signed main() {
//    freopen("input","r",stdin);
//    freopen("fuckout","w",stdout);
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "bitset"
#include "queue"
using namespace std;
#define MAXN 200006
#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
#define P 1000000007
typedef long long ll;
int n , m , k , blo;
int c[MAXN];
vi q , t;
void solve() {
    cin >> n;
    rep( i , 1 , n ) scanf("%lld",c + i);
    rep( i , 1 , n - 1 ) c[i] = c[i + 1] - c[i] , q.pb( c[i] );
    rep( i , 1 , n ) scanf("%lld",c + i);
    rep( i , 1 , n - 1 ) c[i] = c[i + 1] - c[i] , t.pb( c[i] );
    sort( all( q ) ) , sort( all( t ) );
    rep( i , 0 , n - 2 ) if( q[i] != t[i] ) return void( puts("No") );
    puts("Yes");
}

signed main() {
//    freopen("input","r",stdin);
//    freopen("fuckout","w",stdout);
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <sstream>
using namespace std;

int C[100011];
int T[100011];
int CC[100011];
int TT[100011];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    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++)
        CC[i] = C[i + 1] - C[i];
    for (int i = 0; i < n - 1; i++)
        TT[i] = T[i + 1] - T[i];
    sort(CC, CC + n - 1);
    sort(TT, TT + n - 1);
    for (int i = 0; i < n - 1; i++)
        if (CC[i] != TT[i])
        {
            cout << "No";
            return 0;
        }
    if (C[0] != T[0])
        cout << "No";
    else
        cout << "Yes";

    return 0;
}


#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> v;
    vector<int> v0;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        v0.push_back(x);
    }
    vector<int> a;
    for (int i = 0; i < n; i++)
    {
        if (i == 0 || i == n - 1)
            a.push_back(0);
        else
            a.push_back(v[i + 1] - v[i + 1] - v[i]);
    }
    if (v[0] != v0[0] || v[n - 1] != v0[n - 1])
        cout << "No";
    else
    {
        for (int i = 1; i < n - 1; i++)
        {
            if (!(v[i] == v0[i] || v[i] + a[i] == v0[i] || v[i] + a[i - 1] == v0[i] || v[i] + a[i + 1] == v0[i] || v[i] + a[i - 1] + a[i] == v0[i] || v[i] + a[i - 1] + a[i + 1] == v0[i] || v[i] + a[i] + a[i + 1] == v0[i] || v[i] + a[i - 1] + a[i]  + a[i + 1] == v0[i]))
                {
                    cout << "No";
                    return 0;

                }

        }
        cout << "Yes";
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<int> v;
	vector<int> v0;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		v.push_back(x);
	}
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		v0.push_back(x);
	}
	vector<int> a;
	for (int i = 0; i < n; i++)
	{
		if (i == 0 || i == n - 1)
			a.push_back(0);
		else
			a.push_back(v[i - 1] + v[i + 1] - 2 * v[i]);
	}
	if (v[0] != v0[0] || v[n - 1] != v0[n - 1])
		cout << "No";
	else
	{
		for (int i = 1; i < n - 1; i++)
		{
			if (!(v[i] == v0[i] || v[i] + a[i] == v0[i] || v[i] + a[i - 1] == v0[i] || v[i] + a[i + 1] == v0[i] || v[i] + a[i - 1] + a[i] == v0[i] || v[i] + a[i - 1] + a[i + 1] == v0[i] || v[i] + a[i] + a[i + 1] == v0[i] || v[i] + a[i - 1] + a[i] + a[i + 1] == v0[i]))
			{
				cout << "No";
				return 0;

			}

		}
		cout << "Yes";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6+10;
typedef long long ll;
const int mod = 2;
typedef pair<int,int> pii;
vector<int> vec;
vector<int> G[maxn];
int n, m, cnt[maxn], a[maxn], c[maxn]; ll ans = 0;
bool check() {
    int l=1, r;
    for (int i=1; i<=n; ++i) {
        if(a[i] == c[i]) l = i, r=i+1;
        while(r<n&&a[r]+a[l] != c[i]+a[r-1]) ++r;
        if(a[i] == c[i]) continue;
        if(a[l]+a[r] != c[i]+a[r-1]) return false;
        ++l;
    }
    return true;
}

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", c+i);
    puts(check()?"Yes": "No");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
typedef long long ll;
vector<int> x, y;
int n, 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) x.push_back(a[i]-a[i-1]), y.push_back(b[i]-b[i-1]);
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    for (int i=0; i<x.size(); ++i) {
        if(x[i]!=y[i]) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


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

#define ll long long
#define double long double
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T = 1,n,m,k;

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> T;
    while(T--){
        ll l;
        cin >> n >> l;
        double a[n];
        for(int i=0;i<n;i++)
            cin >> a[i];

        double s1 = 1.0;
        double s2 = 1.0;
        double ans = 0;

        ll i=0, j=n-1;
        double pos1 = 0;
        double pos2 = l;

        while(i<=j){

            double p1 = (a[i] - pos1) / s1;
            double p2 = (pos2 - a[j]) / s2;
            if(p1 < p2){
                pos1 = a[i];
                i++;
                s1 = s1 + 1.0;
                pos2 = pos2 - (s2 * p1);
                ans = ans + p1;
            }
            else if(p1 > p2){
                pos2 = a[j];
                j--;
                s2 = s2 + 1.0;
                pos1 = pos1 + (s1 * p2);
                ans = ans + p2;
            }
            else{
                pos1 = pos1 + s1 * p1;
                i++;
                pos2 = pos2 - s2 * p2;
                j--;
                s1 = s1 + 1.0;
                s2 = s2 + 1.0;
                ans = ans + p1;
            }
            // cout << ans << " " << pos1 <<  " " << pos2 << "\n";
        }
        // cout << ans << " " << pos1 <<  " " << pos2 << "\n";
        {
            double d = pos2 - pos1;
            ans = ans + (d * 1.0) / (s1 + s2);
        }
        cout << ans << setprecision(6) << "\n";

    }

    return 0;
}


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

#define ll long long
#define double long double
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T = 1,n,m,k;

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> T;
    while(T--){
        ll l;
        cin >> n >> l;
        double a[n];
        for(int i=0;i<n;i++)
            cin >> a[i];
        sort(a, a+n);

        double s1 = 1.0;
        double s2 = 1.0;
        double ans = 0;

        ll i=0, j=n-1;
        double pos1 = 0;
        double pos2 = l;

        while(i<=j){
            double p1 = (a[i] - pos1) / s1;
            double p2 = (pos2 - a[j]) / s2;
            if(p1 < p2){
                pos1 = a[i];
                i++;
                s1 = s1 + 1.0;
                pos2 = pos2 - (s2 * p1);
                ans = ans + p1;
            }
            else if(p1 > p2){
                pos2 = a[j];
                j--;
                s2 = s2 + 1.0;
                pos1 = pos1 + (s1 * p2);
                ans = ans + p2;
            }
            else{
                pos1 = a[i];
                i++;
                pos2 = a[j];
                j--;
                s1 = s1 + 1.0;
                s2 = s2 + 1.0;
                ans = ans + p1;
            }
            // cout << ans << " " << pos1 <<  " " << pos2 << "\n";
        }
        // cout << ans << " " << pos1 <<  " " << pos2 << "\n";
        if(pos2 >= pos1){
            double d = pos2 - pos1;
            ans = ans + d / (s1 + s2);
        }
        cout << ans << setprecision(50) << "\n";

    }

    return 0;
}