#include <bits/stdc++.h>
#define ll long long
#define res register int
#define pi pair<int,int>
#define fi first
#define se second
#define N 600005
#define inf 0x3f3f3f3f
using namespace std;
int top, n, a[N], b[N], id[N];
pi st[N];
vector<pair<pi, int> > Ans;
inline int read(){
    res w = 0, X = 0; register char ch = 0;
    while(!isdigit(ch)){w |= ch == '-'; ch = getchar();}
    while(isdigit(ch)){X = (X << 1) + (X << 3) + (ch ^ 48); ch = getchar();}
    return w ? -X : X;
}
inline bool cmp(res x, res y){
	return a[x] < a[y];
}
int main(){
	n = read();
	for(res i = 1; i <= n; i++)
	  a[i] = read();
	for(res i = 1; i <= n; i++)
	  b[i] = read();
	for(res i = 1; i <= n; i++)
	  id[i] = i;
	sort(id + 1, id + n + 1, cmp);
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	for(res i = 1; i <= n; i++){
		res dis = b[i] - a[i];
		if(dis > 0)
		  st[++top] = make_pair(id[i], dis);
		else{
			dis = -dis;
			for(; top && dis;){
				res move = min(dis, st[top].se);
				dis -= move;
				st[top].se -= move;
				Ans.push_back(make_pair(make_pair(st[top].fi, id[i]), move));
				if(!st[top].se) top--;
			}
			if(!top && dis){
				puts("NO");
				return 0;
			}
		}
	}
	if(top){
		puts("NO");
		return 0;
	}
	puts("YES");
	printf("%d\n", Ans.size());
	for(auto x : Ans)
	  printf("%d %d %d\n", x.fi.fi, x.fi.se, x.se);
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define res register int
#define pi pair<int,int>
#define fi first
#define se second
#define N 600005
#define inf 0x3f3f3f3f
using namespace std;
int top, n, a[N], b[N], id[N];
pi st[N];
vector<pair<pi, int> > Ans;
inline int read(){
    res w = 0, X = 0; register char ch = 0;
    while(!isdigit(ch)){w |= ch == '-'; ch = getchar();}
    while(isdigit(ch)){X = (X << 1) + (X << 3) + (ch ^ 48); ch = getchar();}
    return w ? -X : X;
}
inline bool cmp(res x, res y){
	return a[x] < a[y];
}
int main(){
	n = read();
	for(res i = 1; i <= n; i++)
	  a[i] = read();
	for(res i = 1; i <= n; i++)
	  b[i] = read();
	for(res i = 1; i <= n; i++)
	  id[i] = i;
	sort(id + 1, id + n + 1, cmp);
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	for(res i = 1; i <= n; i++){
		res dis = b[i] - a[i];
		if(dis > 0)
		  st[++top] = make_pair(id[i], dis);
		else{
			dis = -dis;
			for(; top && dis;){
				res move = min(dis, st[top].se);
				dis -= move;
				st[top].se -= move;
				Ans.push_back(make_pair(make_pair(st[top].fi, id[i]), move));
				if(!st[top].se) top--;
			}
			if(!top && dis){
				puts("NO");
				return 0;
			}
		}
	}
	puts("YES");
	printf("%d\n", Ans.size());
	for(auto x : Ans)
	  printf("%d %d %d\n", x.fi.fi, x.fi.se, x.se);
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define res register int
#define pi pair<int,int>
#define fi first
#define se second
#define N 600005
#define inf 0x3f3f3f3f
using namespace std;
int top, n, a[N], b[N];
pi st[N];
vector<pair<pi, int> > Ans;
inline int read(){
    res w = 0, X = 0; register char ch = 0;
    while(!isdigit(ch)){w |= ch == '-'; ch = getchar();}
    while(isdigit(ch)){X = (X << 1) + (X << 3) + (ch ^ 48); ch = getchar();}
    return w ? -X : X;
}
int main(){
	n = read();
	for(res i = 1; i <= n; i++)
	  a[i] = read();
	for(res i = 1; i <= n; i++)
	  b[i] = read();
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	for(res i = 1; i <= n; i++){
		res dis = b[i] - a[i];
		if(dis > 0)
		  st[++top] = make_pair(i, dis);
		else{
			dis = -dis;
			for(; top && dis;){
				res move = min(dis, st[top].se);
				dis -= move;
				st[top].se -= move;
				Ans.push_back(make_pair(make_pair(st[top].fi, i), move));
				if(!st[top].se) top--;
			}
			if(!top && dis){
				puts("NO");
				return 0;
			}
		}
	}
	puts("YES");
	printf("%d\n", Ans.size());
	for(auto x : Ans)
	  printf("%d %d %d\n", x.fi.fi, x.fi.se, x.se);
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define res register int
#define pi pair<int,int>
#define fi first
#define se second
#define N 600005
#define inf 0x3f3f3f3f
using namespace std;
int top, n, a[N], b[N];
pi st[N];
vector<pair<pi, int> > Ans;
inline int read(){
    res w = 0, X = 0; register char ch = 0;
    while(!isdigit(ch)){w |= ch == '-'; ch = getchar();}
    while(isdigit(ch)){X = (X << 1) + (X << 3) + (ch ^ 48); ch = getchar();}
    return w ? -X : X;
}
int main(){
	n = read();
	for(res i = 1; i <= n; i++)
	  a[i] = read();
	for(res i = 1; i <= n; i++)
	  b[i] = read();
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	for(res i = 1; i <= n; i++){
		res dis = b[i] - a[i];
		if(dis > 0)
		  st[++top] = make_pair(i, dis);
		else{
			dis = -dis;
			for(; top && dis;){
				res move = min(dis, st[top].se);
				dis -= move;
				st[top].se -= move;
				Ans.push_back(make_pair(make_pair(st[top].fi, i), move));
				if(!st[top].se) top--;
			}
			if(!top && dis){
				puts("NO");
				return 0;
			}
		}
	}
	puts("YES");
	for(auto x : Ans)
	  printf("%d %d %d\n", x.fi.fi, x.fi.se, x.se);
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#define ll long long
using namespace std;
int n,a[300005],b[300005];
int x[2000005],y[2000005],d[2000005],tot;
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >q1;
priority_queue<pair<int,int> >q2;
int main()
{
	ll s=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		s+=a[i];
		q1.push(make_pair(a[i],i));
		q2.push(make_pair(a[i],i));
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
		s-=b[i];
	}
	if(s!=0)
	{
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	sort(b+1,b+n+1);
	int now=1;
	while(!q1.empty())
	{
		int node=q1.top().second;
		int v=q1.top().first;
		q1.pop();
		if(a[node]!=v)continue;
		if(v==b[now])
		{
			now++;
			continue;
		}
		int node2=q2.top().second;
		int v2=q2.top().first;
		q2.pop();
		while(a[node2]!=v2)
		{
			node2=q2.top().second;
			v2=q2.top().first;
			q2.pop();
		}
		int dd=min(b[now]-v,v2-b[now]);
		x[++tot]=node;
		y[tot]=node2;
		d[tot]=dd;
		a[node]+=dd;
		a[node2]-=dd;
		if(a[node]==b[now])
		{
			q1.push(make_pair(a[node2],node2));
			q2.push(make_pair(a[node2],node2));
		}
		else
		{
			q1.push(make_pair(a[node],node));
			q2.push(make_pair(a[node],node));
		}
		now++;
	}
	printf("%d\n",tot);
	for(int i=1;i<=tot;i++)printf("%d %d %d\n",x[i],y[i],d[i]);
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
int n,a[300005],b[300005],saa[300005],sab[300005],tot,x[3000005],y[3000050],d[3000005];
queue<pair<int,int> >q;
bool cmpa(int x,int y)
{
	return a[x]<a[y];
}
bool cmpb(int x,int y)
{
	return b[x]<b[y];
}
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=1;i<=n;i++)saa[i]=sab[i]=i;
	sort(saa+1,saa+n+1,cmpa);
	sort(sab+1,sab+n+1,cmpb);
	for(int i=1;i<=n;i++)
	{
		if(a[saa[i]]==b[sab[i]])continue;
		if(a[saa[i]]>b[sab[i]])
		{
			int val=a[saa[i]]-b[sab[i]];
			while(val&&!q.empty())
			{
				int node=q.front().second;
				int v=q.front().first;
				q.pop();
				if(v<=val)
				{
					val-=v;
					x[++tot]=node,y[tot]=saa[i];
					d[tot]=v;
				}
				else
				{
					v-=val;
					val=0;
					x[++tot]=node,y[tot]=saa[i];
					d[tot]=val;
					q.push(make_pair(v,node));
				}
			}
			if(val)
			{
				printf("NO\n");
				return 0;
			}
		}
		else q.push(make_pair(b[sab[i]]-a[saa[i]],saa[i]));
	}
	if(!q.empty())
	{
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	printf("%d\n",tot);
	for(int i=1;i<=tot;i++)printf("%d %d %d\n",x[i],y[i],d[i]);
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
int n,a[300005],b[300005],saa[300005],sab[300005],tot,x[3000005],y[3000050],d[3000005];
queue<pair<int,int> >q;
bool cmpa(int x,int y)
{
	return a[x]<a[y];
}
bool cmpb(int x,int y)
{
	return b[x]<b[y];
}
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=1;i<=n;i++)saa[i]=sab[i]=i;
	sort(saa+1,saa+n+1,cmpa);
	sort(sab+1,sab+n+1,cmpb);
	for(int i=1;i<=n;i++)
	{
		if(a[saa[i]]==b[sab[i]])continue;
		if(a[saa[i]]>b[sab[i]])
		{
			int val=a[saa[i]]-b[sab[i]];
			while(val&&!q.empty())
			{
				int node=q.front().second;
				int v=q.front().first;
				q.pop();
				if(v<=val)
				{
					val-=v;
					x[++tot]=node,y[tot]=saa[i];
					d[tot]=v;
				}
				else
				{
					v-=val;
					x[++tot]=node,y[tot]=saa[i];
					d[tot]=val;
					val=0;
					q.push(make_pair(v,node));
				}
			}
			if(val)
			{
				printf("NO\n");
				return 0;
			}
		}
		else q.push(make_pair(b[sab[i]]-a[saa[i]],saa[i]));
	}
	if(!q.empty())
	{
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	printf("%d\n",tot);
	for(int i=1;i<=tot;i++)printf("%d %d %d\n",x[i],y[i],d[i]);
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#define ll long long
using namespace std;
int n,a[300005],b[300005];
int x[2000005],y[2000005],d[2000005],tot;
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >q1;
priority_queue<pair<int,int> >q2;
int main()
{
	ll s=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		s+=a[i];
		q1.push(make_pair(a[i],i));
		q2.push(make_pair(a[i],i));
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
		s-=b[i];
	}
	if(s!=0)
	{
		printf("NO\n");
		return 0;
	}
	sort(b+1,b+n+1);
	int now=1;
	while(!q1.empty())
	{
		int node=q1.top().second;
		int v=q1.top().first;
		q1.pop();
		if(a[node]!=v)continue;
		if(v==b[now])
		{
			now++;
			continue;
		}
		int node2=q2.top().second;
		int v2=q2.top().first;
		q2.pop();
		while(a[node2]!=v2)
		{
			node2=q2.top().second;
			v2=q2.top().first;
			q2.pop();
		}
		int dd=min(b[now]-v,v2-b[now]);
		if(dd<0)
		{
			printf("NO\n");
			return 0;
		}
		x[++tot]=node;
		y[tot]=node2;
		d[tot]=dd;
		a[node]+=dd;
		a[node2]-=dd;
		if(a[node]==b[now])
		{
			q1.push(make_pair(a[node2],node2));
			q2.push(make_pair(a[node2],node2));
		}
		else
		{
			q1.push(make_pair(a[node],node));
			q2.push(make_pair(a[node],node));
		}
		now++;
	}
	printf("YES\n");
	printf("%d\n",tot);
	for(int i=1;i<=tot;i++)printf("%d %d %d\n",x[i],y[i],d[i]);
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
int n,a[300005],b[300005],saa[300005],sab[300005],tot,x[3000005],y[3000050],d[3000005];
queue<pair<int,int> >q;
bool cmpa(int x,int y)
{
	return a[x]<a[y];
}
bool cmpb(int x,int y)
{
	return b[x]<b[y];
}
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=1;i<=n;i++)saa[i]=sab[i]=i;
	sort(saa+1,saa+n+1,cmpa);
	sort(sab+1,sab+n+1,cmpb);
	for(int i=1;i<=n;i++)
	{
		if(a[saa[i]]==b[sab[i]])continue;
		if(a[saa[i]]>b[sab[i]])
		{
			int val=a[saa[i]]-b[sab[i]];
			while(val&&!q.empty())
			{
				int node=q.front().second;
				int v=q.front().first;
				q.pop();
				if(v<=val)
				{
					val-=v;
					x[++tot]=node,y[tot]=saa[i];
					d[tot]=v;
				}
				else
				{
					v-=val;
					val=0;
					x[++tot]=node,y[tot]=saa[i];
					d[tot]=val;
					q.push(make_pair(v,node));
				}
			}
			if(val)
			{
				printf("NO\n");
				return 0;
			}
		}
		else q.push(make_pair(b[sab[i]]-a[saa[i]],saa[i]));
	}
	if(!q.empty())
	{
		printf("NO\n");
		return 0;
	}
	printf("%d\n",tot);
	for(int i=1;i<=tot;i++)printf("%d %d %d\n",x[i],y[i],d[i]);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
struct node
{
    int x,y,z;
};
struct Node
{
    int val;
    int pos;
    friend bool operator < (const Node &a,const Node &b)
    {
        return a.val>b.val;
    }
}s[300005],t[300005];
int n;
long long s1,s2;
vector<node> v;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s[i].val;
        s[i].pos=i;
    }
    for(int i=1;i<=n;i++)
    {
        cin>>t[i].val;
        t[i].pos=i;
    }
    for(int i=1;i<=n;i++)
    {
        s1+=s[i].val;
        s2+=t[i].val;
    }
    if(s1!=s2)
    {
        cout<<"NO";
        return 0;
    }
    sort(s+1,s+n+1);
    sort(t+1,t+n+1);
    for(int i=1;i<=n;i++)
    {
        int temp=s[i].val-t[i].val;
        for(int j=1;j<=n&&temp!=0;j++)
        {
            if(i==j)
                continue;
            if(s[j].val<t[j].val)
            {
                v.push_back((node){s[j].pos,s[i].pos,min(temp,t[j].val-s[j].val)});
                int tt=min(temp,t[j].val-s[j].val);
                temp-=tt;
				s[j].val+=tt;
            }
        }
        if(temp)
        {
            cout<<"NO";
            return 0;
        }
        s[i].val=t[i].val;
    }
    cout<<"YES\n";
    cout<<v.size()<<endl;
    for(int i=0;i<v.size();i++)
        cout<<v[i].x<<' '<<v[i].y<<' '<<v[i].z<<endl;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
struct node
{
    int x,y,z;
};
struct Node
{
    int val;
    int pos;
    friend bool operator < (const Node &a,const Node &b)
    {
        return a.val>b.val;
    }
}s[300005],t[300005];
int n;
long long s1,s2;
vector<node> v;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s[i].val;
        s[i].pos=i;
    }
    for(int i=1;i<=n;i++)
    {
        cin>>t[i].val;
        t[i].pos=i;
    }
    for(int i=1;i<=n;i++)
    {
        s1+=s[i].val;
        s2+=t[i].val;
    }
    if(s1!=s2)
    {
        cout<<"NO";
        return 0;
    }
    sort(s+1,s+n+1);
    sort(t+1,t+n+1);
    for(int i=1;i<=n;i++)
    {
        int temp=s[i].val-t[i].val;
        for(int j=1;j<=n&&temp!=0;j++)
        {
            if(i==j)
                continue;
            if(s[j].val<t[j].val)
            {
                v.push_back((node){s[i].pos,s[j].pos,min(temp,t[j].val-s[j].val)});
                int tt=min(temp,t[j].val-s[j].val);
                temp-=tt;
				s[j].val+=tt;
            }
        }
        if(temp)
        {
            cout<<"NO";
            return 0;
        }
        s[i].val=t[i].val;
    }
    cout<<"YES\n";
    cout<<v.size()<<endl;
    for(int i=0;i<v.size();i++)
        cout<<v[i].x<<' '<<v[i].y<<' '<<v[i].z<<endl;
    return 0;
}


#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
struct node
{
    int x,y,z;
};
struct Node
{
    int val;
    int pos;
    friend bool operator < (const Node &a,const Node &b)
    {
        return a.val>b.val;
    }
}s[300005],t[300005];
int n;
long long s1,s2;
vector<node> v;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&s[i].val);
        s1+=s[i].val;
        s[i].pos=i;
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&t[i].val);
        s2+=t[i].val;
        t[i].pos=i;
    }
    if(s1!=s2)
    {
        cout<<"NO";
        return 0;
    }
    sort(s+1,s+n+1);
    sort(t+1,t+n+1);
    for(int i=1;i<=n;i++)
    {
        int temp=s[i].val-t[i].val;
        for(int j=1;j<=n&&temp!=0;j++)
        {
            if(i==j)
                continue;
            if(s[j].val<t[j].val)
            {
                v.push_back((node){s[j].pos,s[i].pos,min(temp,t[j].val-s[j].val)});
                int tt=min(temp,t[j].val-s[j].val);
                temp-=tt;
				s[j].val+=tt;
            }
        }
        if(temp)
        {
            cout<<"NO";
            return 0;
        }
        s[i].val=t[i].val;
    }
    cout<<"YES\n";
    cout<<v.size()<<endl;
    for(int i=0;i<v.size();i++)
        printf("%d %d %d\n",v[i].x,v[i].y,v[i].z);
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
using namespace std;
struct node
{
    int x,y,z;
};
struct Node
{
    int val;
    int pos;
    friend bool operator < (const Node &a,const Node &b)
    {
        return a.val>b.val;
    }
}s[300005],t[300005];
int n;
long long s1,s2;
vector<node> v;
set<int> a;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&s[i].val);
        s1+=s[i].val;
        s[i].pos=i;
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&t[i].val);
        s2+=t[i].val;
        t[i].pos=i;
    }
    if(s1!=s2)
    {
        cout<<"NO";
        return 0;
    }
    sort(s+1,s+n+1);
    sort(t+1,t+n+1);
    for(int i=1;i<=n;i++)
        if(s[i].val<t[i].val)
            a.insert(i);
    for(int i=1;i<=n;i++)
    {
        queue<int> q;
        int temp=s[i].val-t[i].val;
        for(set<int>::iterator it=a.begin();it!=a.end()&&temp!=0;it++)
        {
            int j=(*it);
            if(i==j)
                continue;
            if(s[j].val<t[j].val)
            {
                v.push_back((node){s[j].pos,s[i].pos,min(temp,t[j].val-s[j].val)});
                int tt=min(temp,t[j].val-s[j].val);
                temp-=tt;
				s[j].val+=tt;
            }
            if(s[j].val==t[j].val)
                q.push(j);
        }
        while(!q.empty())
        {
            a.erase(q.front());
            q.pop();
        }
        if(temp)
        {
            cout<<"NO";
            return 0;
        }
        s[i].val=t[i].val;
        a.erase(i);
    }
    cout<<"YES\n";
    cout<<v.size()<<endl;
    for(int i=0;i<v.size();i++)
        printf("%d %d %d\n",v[i].x,v[i].y,v[i].z);
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
struct node
{
    int x,y,z;
};
struct Node
{
    int val;
    int pos;
    friend bool operator < (const Node &a,const Node &b)
    {
        return a.val>b.val;
    }
}s[300005],t[300005];
int n;
long long s1,s2;
vector<node> v;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&s[i].val);
        s[i].pos=i;
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&t[i].val);
        t[i].pos=i;
    }
    for(int i=1;i<=n;i++)
    {
        s1+=s[i].val;
        s2+=t[i].val;
    }
    if(s1!=s2)
    {
        cout<<"NO";
        return 0;
    }
    sort(s+1,s+n+1);
    sort(t+1,t+n+1);
    for(int i=1;i<=n;i++)
    {
        int temp=s[i].val-t[i].val;
        for(int j=1;j<=n&&temp!=0;j++)
        {
            if(i==j)
                continue;
            if(s[j].val<t[j].val)
            {
                v.push_back((node){s[j].pos,s[i].pos,min(temp,t[j].val-s[j].val)});
                int tt=min(temp,t[j].val-s[j].val);
                temp-=tt;
				s[j].val+=tt;
            }
        }
        if(temp)
        {
            cout<<"NO";
            return 0;
        }
        s[i].val=t[i].val;
    }
    cout<<"YES\n";
    cout<<v.size()<<endl;
    for(int i=0;i<v.size();i++)
        printf("%d %d %d\n",v[i].x,v[i].y,v[i].z);
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
struct node
{
    int x,y,z;
};
struct Node
{
    int val;
    int pos;
    friend bool operator < (const Node &a,const Node &b)
    {
        return a.val>b.val;
    }
}s[300005],t[300005];
int n;
long long s1,s2;
vector<node> v;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s[i].val;
        s[i].pos=i;
    }
    for(int i=1;i<=n;i++)
    {
        cin>>t[i].val;
        t[i].pos=i;
    }
    for(int i=1;i<=n;i++)
    {
        s1+=s[i].val;
        s2+=t[i].val;
    }
    if(s1!=s2)
    {
        cout<<"NO";
        return 0;
    }
    sort(s+1,s+n+1);
    sort(t+1,t+n+1);
    for(int i=1;i<=n;i++)
    {
        int temp=s[i].val-t[i].val;
        for(int j=1;j<=n&&temp!=0;j++)
        {
            if(i==j)
                continue;
            if(s[j].val<t[j].val)
            {
                v.push_back((node){s[j].pos,s[i].pos,min(temp,t[j].val-s[j].val)});
                int tt=min(temp,t[j].val-s[j].val);
                temp-=tt;
				s[j].val+=tt;
            }
        }
        if(temp)
        {
            cout<<"NO";
            return 0;
        }
        s[i].val=t[i].val;
    }
    cout<<"YES\n";
    cout<<v.size()<<endl;
    for(int i=0;i<v.size();i++)
        cout<<v[i].x<<' '<<v[i].y<<' '<<v[i].z<<endl;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
using namespace std;
struct node
{
    int x,y,z;
};
struct Node
{
    int val;
    int pos;
    friend bool operator < (const Node &a,const Node &b)
    {
        return a.val>b.val;
    }
}s[300005],t[300005];
int n;
long long s1,s2;
vector<node> v;
set<int> a;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&s[i].val);
        s1+=s[i].val;
        s[i].pos=i;
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&t[i].val);
        s2+=t[i].val;
        t[i].pos=i;
    }
    if(s1!=s2)
    {
        cout<<"NO";
        return 0;
    }
    sort(s+1,s+n+1);
    sort(t+1,t+n+1);
    for(int i=1;i<=n;i++)
        if(s[i].val<t[i].val)
            a.insert(i);
    for(int i=1;i<=n;i++)
    {
        queue<int> q;
        int temp=s[i].val-t[i].val;
        for(set<int>::iterator it=a.begin();it!=a.end()&&temp!=0;it++)
        {
            int j=(*it);
            if(j<i)
            {
                q.push(j);
                continue;
            }
            if(s[j].val<t[j].val)
            {
                v.push_back((node){s[j].pos,s[i].pos,min(temp,t[j].val-s[j].val)});
                int tt=min(temp,t[j].val-s[j].val);
                temp-=tt;
				s[j].val+=tt;
            }
            if(s[j].val==t[j].val)
                q.push(j);
        }
        while(!q.empty())
        {
            a.erase(q.front());
            q.pop();
        }
        if(temp)
        {
            cout<<"NO";
            return 0;
        }
        s[i].val=t[i].val;
        a.erase(i);
    }
    for(int i=1;i<=n;i++)
        if(s[i].val!=t[i].val)
        {
            cout<<"NO";
            return 0;
        }
    cout<<"YES\n";
    cout<<v.size()<<endl;
    for(int i=0;i<v.size();i++)
        printf("%d %d %d\n",v[i].x,v[i].y,v[i].z);
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
using namespace std;
struct node
{
    int x,y,z;
};
struct Node
{
    int val;
    int pos;
    friend bool operator < (const Node &a,const Node &b)
    {
        return a.val>b.val;
    }
}s[300005],t[300005];
int n;
long long s1,s2;
vector<node> v;
set<int> a;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&s[i].val);
        s1+=s[i].val;
        s[i].pos=i;
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&t[i].val);
        s2+=t[i].val;
        t[i].pos=i;
    }
    if(s1!=s2)
    {
        cout<<"NO";
        return 0;
    }
    sort(s+1,s+n+1);
    sort(t+1,t+n+1);
    for(int i=1;i<=n;i++)
        if(s[i].val<t[i].val)
            a.insert(i);
    for(int i=1;i<=n;i++)
    {
        queue<int> q;
        int temp=s[i].val-t[i].val;
        for(set<int>::iterator it=a.begin();it!=a.end()&&temp!=0;it++)
        {
            int j=(*it);
            if(i==j)
                continue;
            if(s[j].val<t[j].val)
            {
                v.push_back((node){s[j].pos,s[i].pos,min(temp,min(t[j].val-s[j].val,(t[i].val+temp+s[j].val)/2))});
                int tt=min(temp,min(t[j].val-s[j].val,(t[i].val+temp+s[j].val)/2));
                temp-=tt;
				s[j].val+=tt;
            }
            if(s[j].val==t[j].val)
                q.push(j);
        }
        while(!q.empty())
        {
            a.erase(q.front());
            q.pop();
        }
        if(temp)
        {
            cout<<"NO";
            return 0;
        }
        s[i].val=t[i].val;
        a.erase(i);
    }
    cout<<"YES\n";
    cout<<v.size()<<endl;
    for(int i=0;i<v.size();i++)
        printf("%d %d %d\n",v[i].x,v[i].y,v[i].z);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,sum1,sum2,ans,pos=1,t[300001],d[300001],nxt[300001],a1[1500001],a2[1500001],a3[1500001];
struct lmz{int s,id;}q[300001];
bool cmp(lmz x,lmz y){return x.s<y.s;}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&q[i].s),q[i].id=i,sum1+=q[i].s;
	for(int i=1;i<=n;i++)scanf("%d",&t[i]),sum2+=t[i];
	if(sum1!=sum2){printf("NO");return 0;}
	sort(q+1,q+n+1,cmp),sort(t+1,t+n+1);
	for(int i=1;i<=n;i++)d[i]=t[i]-q[i].s;
	for(int i=1;i<=n;i++){
		if(d[i]<0){printf("NO");return 0;}
		if(!d[i])continue;
		while(d[i]){
			while(d[pos]>=0&&pos<=n)pos++;
			if(pos>n){printf("NO");return 0;}
			int dis=min((q[pos].s-q[i].s)/2,d[i]);
			a1[++ans]=q[i].id,a2[ans]=q[pos].id,a3[ans]=dis;
			d[pos]+=dis,d[i]-=dis,q[i].s+=dis,q[pos].s-=dis;
		}
	}
	printf("YES\n%d\n",ans);
	for(int i=1;i<=ans;i++)printf("%d %d %d\n",a1[i],a2[i],a3[i]);
}


#include<bits/stdc++.h>
using namespace std;
int n,sum1,sum2,ans,pos,t[300001],d[300001],nxt[300001],a1[1500001],a2[1500001],a3[1500001];
struct lmz{int s,id;}q[300001];
bool cmp(lmz x,lmz y){return x.s<y.s;}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&q[i].s),q[i].id=i,sum1+=q[i].s;
	for(int i=1;i<=n;i++)scanf("%d",&t[i]),sum2+=t[i];
	if(sum1!=sum2){printf("NO");return 0;}
	sort(q+1,q+n+1,cmp),sort(t+1,t+n+1);
	for(int i=1;i<=n;i++)d[i]=t[i]-q[i].s;
	for(int i=1;i<=n;i++){
		if(d[i]<0){printf("NO");return 0;}
		if(!d[i])continue;
		pos=max(i,pos);
		while(d[pos]>=0&&pos<=n)pos++;
		if(pos>n){printf("NO");return 0;}
		a1[++ans]=q[i].id,a2[ans]=q[pos].id,a3[ans]=d[i],d[pos]+=d[i];
	}
	printf("YES\n%d\n",ans);
	for(int i=1;i<=ans;i++)printf("%d %d %d\n",a1[i],a2[i],a3[i]);
}


#include<bits/stdc++.h>
using namespace std;
int n,sum1,sum2,ans,pos=1,t[300001],d[300001],nxt[300001],a1[1500001],a2[1500001],a3[1500001];
struct lmz{int s,id;}q[300001];
bool cmp(lmz x,lmz y){return x.s<y.s;}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&q[i].s),q[i].id=i,sum1+=q[i].s;
	for(int i=1;i<=n;i++)scanf("%d",&t[i]),sum2+=t[i];
	if(sum1!=sum2){printf("NO");return 0;}
	sort(q+1,q+n+1,cmp),sort(t+1,t+n+1);
	for(int i=1;i<=n;i++)d[i]=t[i]-q[i].s;
	for(int i=1;i<=n;i++){
		if(d[i]<0){printf("NO");return 0;}
		if(!d[i])continue;
		while(d[pos]>=0&&pos<=n)pos++;
		if(pos>n){printf("NO");return 0;}
		a1[++ans]=q[i].id,a2[ans]=q[pos].id,a3[ans]=d[i],d[pos]+=d[i];
	}
	printf("YES\n%d\n",ans);
	for(int i=1;i<=ans;i++)printf("%d %d %d\n",a1[i],a2[i],a3[i]);
}


#include<bits/stdc++.h>
using namespace std;
int n,sum1,sum2,ans,pos,t[300001],d[300001],nxt[300001],a1[1500001],a2[1500001],a3[1500001];
struct lmz{int s,id;}q[300001];
bool cmp(lmz x,lmz y){return x.s<y.s;}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&q[i].s),q[i].id=i,sum1+=q[i].s;
	for(int i=1;i<=n;i++)scanf("%d",&t[i]),sum2+=t[i];
	if(sum1!=sum2){printf("NO");return 0;}
	sort(q+1,q+n+1,cmp),sort(t+1,t+n+1);
	for(int i=1;i<=n;i++)d[i]=t[i]-q[i].s;
	for(int i=1;i<=n;i++){
		if(d[i]<0){printf("NO");return 0;}
		if(!d[i])continue;
		pos=max(i,pos);
		while(1){
			while(d[pos]>=0&&pos<=n)pos++;
			if(pos>n){printf("NO");return 0;}
			a1[++ans]=q[i].id,a2[ans]=q[pos].id,a3[ans]=d[i];
			if(d[i]+d[pos]<=0){d[pos]+=d[i];break;}
			d[i]+=d[pos],d[pos]=0;
		}
	}
	printf("YES\n%d\n",ans);
	for(int i=1;i<=ans;i++)printf("%d %d %d\n",a1[i],a2[i],a3[i]);
}


#include<bits/stdc++.h>
using namespace std;
int n,sum1,sum2,ans,pos,t[300001],d[300001],nxt[300001],a1[1500001],a2[1500001],a3[1500001];
struct lmz{int s,id;}q[300001];
bool cmp(lmz x,lmz y){return x.s<y.s;}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&q[i].s),q[i].id=i,sum1+=q[i].s;
	for(int i=1;i<=n;i++)scanf("%d",&t[i]),sum2+=t[i];
	if(sum1!=sum2){printf("NO");return 0;}
	sort(q+1,q+n+1,cmp),sort(t+1,t+n+1);
	for(int i=1;i<=n;i++)d[i]=t[i]-q[i].s;
	for(int i=n;i>=1;i--){
		nxt[i]=pos;
		if(d[i]<0)pos=i;
	}
	for(int i=1;i<=n;i++){
		if(d[i]<0){printf("NO");return 0;}
		if(!d[i])continue;
		pos=i;
		while(1){
			pos=nxt[pos];
			if(!pos){printf("NO");return 0;}
			if(d[pos]>=0)continue;
			a1[++ans]=q[i].id,a2[ans]=q[pos].id,a3[ans]=d[i],d[pos]+=d[i];break;
		}
	}
	printf("YES\n%d\n",ans);
	for(int i=1;i<=ans;i++)printf("%d %d %d\n",a1[i],a2[i],a3[i]);
}


#include<bits/stdc++.h>
using namespace std;
int n,sum1,sum2,ans,pos,t[300001],d[300001],nxt[300001],a1[1500001],a2[1500001],a3[1500001];
struct lmz{int s,id;}q[300001];
bool cmp(lmz x,lmz y){return x.s<y.s;}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&q[i].s),q[i].id=i,sum1+=q[i].s;
	for(int i=1;i<=n;i++)scanf("%d",&t[i]),sum2+=t[i];
	if(sum1!=sum2){printf("NO");return 0;}
	sort(q+1,q+n+1,cmp),sort(t+1,t+n+1);
	for(int i=1;i<=n;i++)d[i]=t[i]-q[i].s;
	for(int i=1;i<=n;i++){
		if(d[i]<0){printf("NO");return 0;}
		if(!d[i])continue;
		pos=max(i,pos);
		while(1){
			while(d[pos]>=0&&pos<=n)pos++;
			if(pos>n){printf("NO");return 0;}
			int dis=min((q[pos].s-q[i].s)/2,d[i]);
			a1[++ans]=q[i].id,a2[ans]=q[pos].id,a3[ans]=dis;
			d[pos]+=dis,d[i]-=dis;
			if(!d[i])break;
		}
	}
	printf("YES\n%d\n",ans);
	for(int i=1;i<=ans;i++)printf("%d %d %d\n",a1[i],a2[i],a3[i]);
}


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

const int N = 3e5 + 5;

typedef class Data {
	public:
		int x, y, z;

		Data(int x, int y, int z) : x(x), y(y), z(z) {	}
} Data;

#define ll long long
#define pii pair<int, int>

int n;
pii s[N];
int t[N];
vector<Data> op;

int main() {
	scanf("%d", &n);
	ll sum = 0;
	for (int i = 1, x; i <= n; i++) {
		scanf("%d", &x);
		s[i] = pii(x, i);
		sum += x;
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", t + i);
		sum -= t[i];
	}
	if (sum) {
		puts("NO");
		return 0;
	}
	sort(s + 1, s + n + 1);
	sort(t + 1, t + n + 1);
	int L = 1, R = n;
	while (L < R) {
		if (s[L].first > t[L] || s[R].first < t[R]) {
			puts("NO");
			return 0;
		}
		if (s[L].first == t[L]) {
			L++;
			continue;
		}
		if (s[R].first == t[R]) {
			R--;
			continue;
		}
		int d = min(t[L] - s[L].first, s[R].first - t[R]);
		op.emplace_back(s[L].second, s[R].second, d);
		s[L].first += d, s[R].first -= d;
	}
	puts("YES");
	printf("%d\n", op.size());
	for (auto d : op) {
		printf("%d %d %d\n", d.x, d.y, d.z);
	}
	return 0;
}


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

const int N = 3e5 + 5;

typedef class Data {
	public:
		int x, y, z;

		Data(int x, int y, int z) : x(x), y(y), z(z) {	}
} Data;

#define ll long long
#define pii pair<int, int>

int n;
pii s[N];
int t[N];
set<pii> S;
vector<Data> op;

int main() {
	scanf("%d", &n);
	ll sum = 0;
	for (int i = 1, x; i <= n; i++) {
		scanf("%d", &x);
		s[i] = pii(x, i);
		sum += x;
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", t + i);
		sum -= t[i];
	}
	if (sum) {
		puts("NO");
		return 0;
	}
	sort(s + 1, s + n + 1);
	sort(t + 1, t + n + 1);
	for (int i = 1; i <= n; i++) {
		if (s[i].first > t[i]) {
			S.insert(pii(s[i].first, i));
		}
	}
	for (int i = 1; i <= n; i++) {
		while (s[i].first < t[i]) {
			set<pii>::iterator p = S.upper_bound(pii(s[i].first, 0));
			if (p == S.end()) {
				break;
			}
			int d = min(t[i] - s[i].first, p->first - t[p->second]);
			op.emplace_back(s[i].second, s[p->second].second, d);
			s[i].first += d, s[p->second].first -= d;
			int id = p->second;
			S.erase(p);
			if (s[id].first > t[id]) {
				S.insert(pii(s[id].first, id));
			}
		}
		if (s[i].first ^ t[i]) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	printf("%d\n", op.size());
	for (auto d : op) {
		printf("%d %d %d\n", d.x, d.y, d.z);
	}
	return 0;
}


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

const int N = 3e5 + 5;

typedef class Data {
	public:
		int x, y, z;

		Data(int x, int y, int z) : x(x), y(y), z(z) {	}
} Data;

#define ll long long
#define pii pair<int, int>

int n;
pii s[N];
int t[N], d[N];
vector<Data> op;

int main() {
	scanf("%d", &n);
	ll sum = 0;
	for (int i = 1, x; i <= n; i++) {
		scanf("%d", &x);
		s[i] = pii(x, i);
		sum += x;
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", t + i);
		sum -= t[i];
	}
	if (sum) {
		puts("NO");
		return 0;
	}
	sort(s + 1, s + n + 1);
	sort(t + 1, t + n + 1);
	sum = 0;
	for (int i = 1; i <= n; i++) {
		d[i] = t[i] - s[i].first;
		if ((sum += d[i]) < 0) {
			puts("NO");
			return 0;
		}
	}
	int p = 1;
	for (int i = 1; i <= n; i++) {
		while (d[i] > 0) {
			while (p <= n && d[p] >= 0)
				p++;
			assert(p <= n && i < p);
			int v = min(d[i], -d[p]);
			op.emplace_back(s[i].second, s[p].second, v);
			d[i] -= v, d[p] += v;
		}
	}
	puts("YES");
	printf("%d\n", (signed) op.size());
	for (auto d : op) {
		printf("%d %d %d\n", d.x, d.y, d.z);
	}
	return 0;
}


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

const int N = 3e5 + 5;

typedef class Data {
	public:
		int x, y, z;

		Data(int x, int y, int z) : x(x), y(y), z(z) {	}
} Data;

#define ll long long
#define pii pair<int, int>

int n;
pii s[N];
int t[N], d[N];
vector<Data> op;

int main() {
	scanf("%d", &n);
	ll sum = 0;
	for (int i = 1, x; i <= n; i++) {
		scanf("%d", &x);
		s[i] = pii(x, i);
		sum += x;
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", t + i);
		sum -= t[i];
	}
	if (sum) {
		puts("NO");
		return 0;
	}
	sort(s + 1, s + n + 1);
	sort(t + 1, t + n + 1);
	sum = 0;
	for (int i = 1; i <= n; i++) {
		d[i] = t[i] - s[i].first;
		if ((sum += d[i]) < 0) {
			puts("-1");
			return 0;
		}
	}
	int p = 1;
	for (int i = 1; i <= n; i++) {
		while (d[i] > 0) {
			while (p <= n && d[p] >= 0)
				p++;
			assert(p <= n && i < p);
			int v = min(d[i], -d[p]);
			op.emplace_back(s[i].second, s[p].second, v);
			d[i] -= v, d[p] += v;
		}
	}
	puts("YES");
	printf("%d\n", (signed) op.size());
	for (auto d : op) {
		printf("%d %d %d\n", d.x, d.y, d.z);
	}
	return 0;
}


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

const int N = 3e5 + 5;

typedef class Data {
	public:
		int x, y, z;

		Data(int x, int y, int z) : x(x), y(y), z(z) {	}
} Data;

#define ll long long
#define pii pair<int, int>

int n;
pii s[N];
int t[N], d[N];
vector<Data> op;

int main() {
	scanf("%d", &n);
	ll sum = 0;
	for (int i = 1, x; i <= n; i++) {
		scanf("%d", &x);
		s[i] = pii(x, i);
		sum += x;
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", t + i);
		sum -= t[i];
	}
	if (sum) {
		puts("NO");
		return 0;
	}
	sort(s + 1, s + n + 1);
	sort(t + 1, t + n + 1, greater<int>());
	sum = 0;
	for (int i = 1; i <= n; i++) {
		d[i] = t[i] - s[i].first;
		if ((sum += d[i]) < 0) {
			puts("-1");
			return 0;
		}
	}
	int p = 1;
	for (int i = 1; i <= n; i++) {
		while (d[i] > 0) {
			while (p <= n && d[p] >= 0)
				p++;
			assert(p <= n && i < p);
			int v = min(d[i], -d[p]);
			op.emplace_back(s[i].second, s[p].second, v);
			d[i] -= v, d[p] += v;
		}
	}
	puts("YES");
	printf("%d\n", (signed) op.size());
	for (auto d : op) {
		printf("%d %d %d\n", d.x, d.y, d.z);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<bits/stdc++.h>
using namespace std;
#define MAXN 300005
typedef long long LL;
#define int LL
int n,sum1,sum2;
struct stone{
	int pos,id;
	bool friend operator < (const stone &x,const stone &y){
		return x.pos<y.pos;
	}
}s[MAXN],t[MAXN];
int sta[MAXN],d[MAXN],stak;
struct ming{
	int i,j,d;
	ming(){}
	ming(int I,int J,int D){
		i=I;j=J;d=D;
	}
};
vector<ming> ans;
signed main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&s[i].pos),s[i].id=i;
	for(int i=1;i<=n;i++)scanf("%d",&t[i].pos),t[i].id=i;
	sort(s+1,s+n+1);sort(t+1,t+n+1);int sum=0;
	for(int i=1;i<=n;i++){
		d[i]=t[i].pos-s[i].pos;sum+=d[i];
		if(sum<0){puts("NO");return 0;}
	}
	if(sum!=0){puts("NO");return 0;}puts("YES");
	for(int i=1;i<=n;i++)
		if(d[i]>0)sta[++stak]=i;
		else if(d[i]<0){
			while(stak){
				int tmp=min(s[i].pos-t[i].pos,t[sta[stak]].pos-s[sta[stak]].pos);
				s[i].pos-=tmp;s[sta[stak]].pos+=tmp;
				ans.push_back(ming(s[sta[stak]].id,s[i].id,tmp));
				if(s[i].pos==t[i].pos)break;--stak;
			}
			assert(s[i].pos==t[i].pos);
		}
	int siz=ans.size();printf("%d\n",siz);
	for(int i=0;i<siz;i++)printf("%lld %ld %lld\n",ans[i].i,ans[i].j,ans[i].d);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define MAXN 300005
typedef long long LL;
template<typename _T>
_T Fabs(_T x){return x<0?-x:x;}
int n,s[MAXN],id[MAXN],t[MAXN],a[MAXN];
struct move{
	int i,j,d;
	move(){}
	move(int I,int J,int D){i=I;j=J;d=D;}
};
vector<move> ans;
vector<int> rig,lef;
bool cmp(int x,int y){return s[x]<s[y];}
signed main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&s[i]),id[i]=i;
	for(int i=1;i<=n;i++)scanf("%d",&t[i]);
	sort(id+1,id+n+1,cmp);LL sum1=0,sum2=0;
	sort(s+1,s+n+1);sort(t+1,t+n+1);
	for(int i=1;i<=n;i++){
		sum1+=1ll*s[i];sum2+=1ll*t[i];
		if(sum2<sum1){puts("NO");return 0;}
	}
	sum1=sum2=0;
	for(int i=n;i>0;i--){
		sum1+=1ll*s[i];sum2+=1ll*t[i];
		if(sum2>sum1){puts("NO");return 0;}
	}
	for(int i=1;i<=n;i++)a[i]=t[i]-s[i];
	for(int i=1;i<=n;i++){
		if(a[i]>0)rig.push_back(i);
		if(a[i]<0)lef.push_back(i);
	}
	int siz1=rig.size(),siz2=lef.size();
	int i=0,j=0;bool fg=false;
	while(i<siz1&&j<siz2){
		//printf("%d %d\n",i,j);
		if(rig[i]>=lef[j]){fg=1;break;}
		int d=min(a[rig[i]],Fabs(a[lef[j]]));
		ans.push_back(move(rig[i],lef[j],d));
		a[rig[i]]-=d;a[lef[j]]+=d;
		if(!a[rig[i]])i++;if(!a[lef[j]])j++;
	}
	if(fg){puts("NO");return 0;}
	int siz=ans.size();puts("YES");printf("%d\n",siz);
	for(int i=0;i<siz;i++)printf("%d %d %d\n",id[ans[i].i],id[ans[i].j],ans[i].d);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define MAXN 300005
typedef long long LL;
template<typename _T>
_T Fabs(_T x){return x<0?-x:x;}
int n,s[MAXN],id[MAXN],t[MAXN],a[MAXN];
struct move{
	int i,j,d;
	move(){}
	move(int I,int J,int D){i=I;j=J;d=D;}
};
vector<move>ans;
vector<int>rig,lef;
bool cmp(int x,int y){return s[x]<s[y];}
signed main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&s[i]),id[i]=i;
	for(int i=1;i<=n;i++)scanf("%d",&t[i]);
	sort(id+1,id+n+1,cmp);LL sum1=0,sum2=0;
	sort(s+1,s+n+1);sort(t+1,t+n+1);
	for(int i=1;i<=n;i++){
		sum1+=1ll*s[i];sum2+=1ll*t[i];
		if(sum2<sum1){puts("NO");return 0;}
	}
	sum1=sum2=0;
	for(int i=n;i>0;i--){
		sum1+=1ll*s[i];sum2+=1ll*t[i];
		if(sum2>sum1){puts("NO");return 0;}
	}
	for(int i=1;i<=n;i++)a[i]=t[i]-s[i];
	for(int i=1;i<=n;i++){
		if(a[i]>0)rig.push_back(i);
		if(a[i]<0)lef.push_back(i);
	}
	int siz1=rig.size(),siz2=lef.size();
	int i=0,j=0;bool fg=false;
	while(i<siz1&&j<siz2){
		//printf("%d %d\n",i,j);
		if(rig[i]>=lef[j]){fg=1;break;}
		int d=min(a[rig[i]],Fabs(a[lef[j]]));
		ans.push_back(move(rig[i],lef[j],d));
		a[rig[i]]-=d;a[lef[j]]+=d;
		if(!a[rig[i]])i++;if(!a[lef[j]])j++;
	}
	if(fg){puts("NO");return 0;}
	int siz=ans.size();puts("YES");printf("%d\n",siz);
	for(int i=0;i<siz;i++)printf("%d %d %d\n",id[ans[i].i],id[ans[i].j],ans[i].d);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<bits/stdc++.h>
using namespace std;
#define MAXN 300005
typedef long long LL;
#define int LL
int n,sum1,sum2;
struct stone{
	int pos,id;
	bool friend operator < (const stone &x,const stone &y){
		return x.pos<y.pos;
	}
}s[MAXN],t[MAXN];
int sta[MAXN],d[MAXN],stak;
struct ming{
	int i,j,d;
	ming(){}
	ming(int I,int J,int D){
		i=I;j=J;d=D;
	}
};
vector<ming> ans;
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&s[i].pos),s[i].id=i;
	for(int i=1;i<=n;i++)scanf("%lld",&t[i].pos),t[i].id=i;
	sort(s+1,s+n+1);sort(t+1,t+n+1);int sum=0;
	for(int i=1;i<=n;i++){
		d[i]=t[i].pos-s[i].pos;sum+=d[i];
		if(sum<0){puts("NO");return 0;}
	}
	if(sum!=0){puts("NO");return 0;}puts("YES");
	for(int i=1;i<=n;i++)
		if(d[i]>0)sta[++stak]=i;
		else if(d[i]<0){
			while(stak){
				int tmp=min(s[i].pos-t[i].pos,t[sta[stak]].pos-s[sta[stak]].pos);
				s[i].pos-=tmp;s[sta[stak]].pos+=tmp;
				ans.push_back(ming(s[sta[stak]].id,s[i].id,tmp));
				if(s[i].pos==t[i].pos)break;--stak;
			}
			assert(s[i].pos==t[i].pos);
		}
	int siz=ans.size();printf("%lld\n",siz);
	for(int i=0;i<siz;i++)printf("%lld %lld %lld\n",ans[i].i,ans[i].j,ans[i].d);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<bits/stdc++.h>
using namespace std;
#define MAXN 300005
typedef long long LL;
int n,sum1,sum2;
struct stone{
	int pos,id;
	bool friend operator < (const stone &x,const stone &y){
		return x.pos<y.pos;
	}
}s[MAXN],t[MAXN];
int sta[MAXN],d[MAXN],stak;
struct ming{
	int i,j,d;
	ming(){}
	ming(int I,int J,int D){
		i=I;j=J;d=D;
	}
};
vector<ming> ans;
signed main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&s[i].pos),s[i].id=i;
	for(int i=1;i<=n;i++)scanf("%d",&t[i].pos),t[i].id=i;
	sort(s+1,s+n+1);sort(t+1,t+n+1);int sum=0;
	for(int i=1;i<=n;i++){
		d[i]=t[i].pos-s[i].pos;sum+=d[i];
		if(sum<0){puts("NO");return 0;}
	}
	if(sum){puts("NO");return 0;}puts("YES");
	for(int i=1;i<=n;i++)
		if(d[i]>0)sta[++stak]=i;
		else if(d[i]<0){
			while(stak){
				int tmp=min(s[i].pos-t[i].pos,t[sta[stak]].pos-s[sta[stak]].pos);
				s[i].pos-=tmp;s[sta[stak]].pos+=tmp;
				ans.push_back(ming(s[sta[stak]].id,s[i].id,tmp));
				if(s[i].pos==t[i].pos)break;--stak;
			}
			assert(s[i].pos==t[i].pos);
		}
	int siz=ans.size();printf("%d\n",siz);
	for(int i=0;i<siz;i++)printf("%d %d %d\n",ans[i].i,ans[i].j,ans[i].d);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define MAXN 300005
typedef long long LL;
template<typename _T>
_T Fabs(_T x){return x<0?-x:x;}
int n,s[MAXN],id[MAXN],t[MAXN],a[MAXN];
struct mov{
	int i,j,d;
	mov(){}
	mov(int I,int J,int D){i=I;j=J;d=D;}
};
vector<mov> ans;
vector<int> rig,lef;
bool cmp(int x,int y){return s[x]<s[y];}
signed main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&s[i]),id[i]=i;
	for(int i=1;i<=n;i++)scanf("%d",&t[i]);
	sort(id+1,id+n+1,cmp);LL sum1=0,sum2=0;
	sort(s+1,s+n+1);sort(t+1,t+n+1);
	for(int i=1;i<=n;i++){
		sum1+=1ll*s[i];sum2+=1ll*t[i];
		if(sum2<sum1){puts("NO");return 0;}
	}
	sum1=sum2=0;
	for(int i=n;i>0;i--){
		sum1+=1ll*s[i];sum2+=1ll*t[i];
		if(sum2>sum1){puts("NO");return 0;}
	}
	for(int i=1;i<=n;i++)a[i]=t[i]-s[i];
	for(int i=1;i<=n;i++){
		if(a[i]>0)rig.push_back(i);
		if(a[i]<0)lef.push_back(i);
	}
	int siz1=rig.size(),siz2=lef.size();
	int i=0,j=0;bool fg=false;
	while(i<siz1&&j<siz2){
		//printf("%d %d\n",i,j);
		if(rig[i]>=lef[j]){fg=1;break;}
		int d=min(a[rig[i]],Fabs(a[lef[j]]));
		ans.push_back(mov(rig[i],lef[j],d));
		a[rig[i]]-=d;a[lef[j]]+=d;
		if(!a[rig[i]])i++;if(!a[lef[j]])j++;
	}
	if(fg){puts("NO");return 0;}
	int siz=ans.size();puts("YES");printf("%d\n",siz);
	for(int i=0;i<siz;i++)printf("%d %d %d\n",id[ans[i].i],id[ans[i].j],ans[i].d);
	return 0;
}


/*
    Author:   TelmaZzzz
    Title:    e
    Date:     2019-06-01-23.51
*/
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
//#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define PB push_back
#define MP make_pair
#define INF 1073741824
#define inf 1152921504606846976
#define pi 3.14159265358979323846
//#pragma comment(linker,"/STACK:10240000,10240000")
//mt19937 rand_(time(0));
const int N=3e5+7,M=2e6;
const long long mod=1e9+7;
inline int read(){int ret=0;char ch=getchar();bool f=1;for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');for(;isdigit(ch);ch=getchar()) ret=(ret<<1)+(ret<<3)+ch-48;return f?ret:-ret;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}//逆元
//int head[N],NEXT[M],ver[M],tot;void link(int u,int v){ver[++tot]=v;NEXT[tot]=head[u];head[u]=tot;}

struct node{
    ll val;
    int id;
}que[N];
ll b[N];
bool cmp(node a,node b){
    return a.val<b.val;
}
vector<pair<pair<int,int>,ll > >ans;
int main(){
    //freopen("1.txt","r",stdin);
    //ios::sync_with_stdio(false);
    int n;
    scanf("%d",&n);
    ll suma=0,sumb=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&que[i].val);
        que[i].id=i;
        suma+=que[i].val;
    }
    for(int i=1;i<=n;i++){
        scanf("%lld",&b[i]);
        sumb+=b[i];
    }
    if(suma!=sumb) {
        puts("NO");
        return 0;
    }
    sort(b+1,b+n+1);
    sort(que+1,que+1+n,cmp);
    int now=n;
    for(int i=1;i<=n;i++){
        while(now>i&&que[now].val==b[now]) now--;
        if(i==now) break;
        if(que[i].val==b[i]) continue;
        while(now>i){
            ll tmp=que[now].val-b[now];
            if(tmp==0){
                now--;
                continue;
            }
            if(b[i]-que[i].val>tmp){
                que[i].val+=tmp;
                que[now].val-=tmp;
                ans.PB(MP(MP(que[i].id,que[now].id),tmp));
                now--;
            }
            else {
                ans.PB(MP(MP(que[i].id,que[now].id),b[i]-que[i].val));
                que[now].val-=(b[i]-que[i].val);
                que[i].val=b[i];
                break;
            }
        }
    }
    bool mark=true;
    for(int i=0;i<ans.size();i++) if(ans[i].second<0) mark=false;
    if(!mark) {
        puts("NO");
        return 0;
    }
    puts("YES");
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();i++){
        printf("%d %d %lld\n",ans[i].first.first,ans[i].first.second,ans[i].second);
    }

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


/*
    Author:   TelmaZzzz
    Title:    e
    Date:     2019-06-01-23.51
*/
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
//#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define PB push_back
#define MP make_pair
#define INF 1073741824
#define inf 1152921504606846976
#define pi 3.14159265358979323846
//#pragma comment(linker,"/STACK:10240000,10240000")
//mt19937 rand_(time(0));
const int N=3e5+7,M=2e6;
const long long mod=1e9+7;
inline int read(){int ret=0;char ch=getchar();bool f=1;for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');for(;isdigit(ch);ch=getchar()) ret=(ret<<1)+(ret<<3)+ch-48;return f?ret:-ret;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}//逆元
//int head[N],NEXT[M],ver[M],tot;void link(int u,int v){ver[++tot]=v;NEXT[tot]=head[u];head[u]=tot;}

struct node{
    ll val;
    int id;
}que[N];
ll b[N];
bool cmp(node a,node b){
    return a.val<b.val;
}
vector<pair<pair<int,int>,ll > >ans;
int main(){
    //freopen("1.txt","r",stdin);
    //ios::sync_with_stdio(false);
    int n;
    scanf("%d",&n);
    ll suma=0,sumb=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&que[i].val);
        que[i].id=i;
        suma+=que[i].val;
    }
    for(int i=1;i<=n;i++){
        scanf("%lld",&b[i]);
        sumb+=b[i];
    }
    if(suma!=sumb) {
        puts("NO");
        return 0;
    }
    sort(b+1,b+n+1);
    sort(que+1,que+1+n,cmp);
    int now=n;
    for(int i=1;i<=n;i++){
        while(now>i&&que[now].val==b[now]) now--;
        if(i==now) break;
        if(que[i].val==b[i]) continue;
        while(1){
            ll tmp=que[now].val-b[now];
            if(b[i]-que[i].val>tmp){
                que[i].val+=tmp;
                que[now].val-=tmp;
                ans.PB(MP(MP(que[i].id,que[now].id),tmp));
                now--;
            }
            else {
                ans.PB(MP(MP(que[i].id,que[now].id),b[i]-que[i].val));
                que[now].val-=(b[i]-que[i].val);
                que[i].val=b[i];
                break;
            }
        }
    }
    puts("YES");
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();i++){
        printf("%d %d %lld\n",ans[i].first.first,ans[i].first.second,ans[i].second);
    }

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


/*
    Author:   TelmaZzzz
    Title:    e
    Date:     2019-06-01-23.51
*/
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
//#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define PB push_back
#define MP make_pair
#define INF 1073741824
#define inf 1152921504606846976
#define pi 3.14159265358979323846
//#pragma comment(linker,"/STACK:10240000,10240000")
//mt19937 rand_(time(0));
const int N=3e5+7,M=2e6;
const long long mod=1e9+7;
inline int read(){int ret=0;char ch=getchar();bool f=1;for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');for(;isdigit(ch);ch=getchar()) ret=(ret<<1)+(ret<<3)+ch-48;return f?ret:-ret;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}//逆元
//int head[N],NEXT[M],ver[M],tot;void link(int u,int v){ver[++tot]=v;NEXT[tot]=head[u];head[u]=tot;}

struct node{
    ll val;
    int id;
}que[N];
ll b[N];
bool cmp(node a,node b){
    return a.val<b.val;
}
vector<pair<pair<int,int>,ll > >ans;
int main(){
    //freopen("1.txt","r",stdin);
    //ios::sync_with_stdio(false);
    int n;
    scanf("%d",&n);
    ll suma=0,sumb=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&que[i].val);
        que[i].id=i;
        suma+=que[i].val;
    }
    for(int i=1;i<=n;i++){
        scanf("%lld",&b[i]);
        sumb+=b[i];
    }
    if(suma!=sumb) {
        puts("NO");
        return 0;
    }
    sort(b+1,b+n+1);
    sort(que+1,que+1+n,cmp);
    int now=n;
    bool mark=true;
    for(int i=1;i<=n;i++){
        while(now>i&&que[now].val==b[now]) now--;
        if(i==now) break;
        if(que[i].val==b[i]) continue;
        if(que[i].val>b[i]) mark=false;
        while(now>i){
            ll tmp=que[now].val-b[now];
            if(tmp<0) mark=false;
            if(tmp==0){
                now--;
                continue;
            }
            if(b[i]-que[i].val>tmp){
                que[i].val+=tmp;
                que[now].val-=tmp;
                ans.PB(MP(MP(que[i].id,que[now].id),tmp));
                now--;
            }
            else {
                ans.PB(MP(MP(que[i].id,que[now].id),b[i]-que[i].val));
                que[now].val-=(b[i]-que[i].val);
                que[i].val=b[i];
                break;
            }
        }
    }
    if(!mark) {
        puts("NO");
        return 0;
    }
    puts("YES");
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();i++){
        printf("%d %d %lld\n",ans[i].first.first,ans[i].first.second,ans[i].second);
    }

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


/*
    Author:   TelmaZzzz
    Title:    e
    Date:     2019-06-01-23.51
*/
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
//#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define PB push_back
#define MP make_pair
#define INF 1073741824
#define inf 1152921504606846976
#define pi 3.14159265358979323846
//#pragma comment(linker,"/STACK:10240000,10240000")
//mt19937 rand_(time(0));
const int N=3e5+7,M=2e6;
const long long mod=1e9+7;
inline int read(){int ret=0;char ch=getchar();bool f=1;for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');for(;isdigit(ch);ch=getchar()) ret=(ret<<1)+(ret<<3)+ch-48;return f?ret:-ret;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}//逆元
//int head[N],NEXT[M],ver[M],tot;void link(int u,int v){ver[++tot]=v;NEXT[tot]=head[u];head[u]=tot;}

struct node{
    ll val;
    int id;
}que[N];
ll b[N];
bool cmp(node a,node b){
    return a.val<b.val;
}
vector<pair<pair<int,int>,ll > >ans;
int main(){
    //freopen("1.txt","r",stdin);
    //ios::sync_with_stdio(false);
    int n;
    scanf("%d",&n);
    ll suma=0,sumb=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&que[i].val);
        que[i].id=i;
        suma+=que[i].val;
    }
    for(int i=1;i<=n;i++){
        scanf("%lld",&b[i]);
        sumb+=b[i];
    }
    if(suma!=sumb) {
        puts("NO");
        return 0;
    }
    sort(b+1,b+n+1);
    sort(que+1,que+1+n,cmp);
    int now=n;
    int l=n-1,r=n;
    bool mark=true;
    while(l<=r&&l>=1){
        if(b[r]>que[r].val){
            mark=false;
            break;
        }
        if(b[l]<que[l].val){
            l--;
            continue;
        }
        if(r==l){
            mark=false;
            break;
        }
        if(b[l]==que[l].val) {
            l--;
            continue;
        }
        if(b[r]==que[r].val){
            r--;
            continue;
        }
        ll tmp=que[r].val-b[r];
//        cout<<tmp<<' '<<l<<' '<<r<<endl;
        if(b[l]-que[l].val>tmp){
            que[l].val+=tmp;
            que[r].val-=tmp;
            ans.PB(MP(MP(que[l].id,que[r].id),tmp));
            r--;
        }
        else {
            ans.PB(MP(MP(que[l].id,que[r].id),b[l]-que[l].val));
            que[r].val-=(b[l]-que[l].val);
            que[l].val=b[l];
            l--;
        }
    }
    for(int i=1;i<=n;i++){
        if(que[i].val!=b[i]) mark=false;
    }
//    for(int i=n;i>=1;i--){
//        while(now>i&&que[now].val==b[now]) now--;
//        if(i==now) break;
//        if(que[i].val==b[i]) continue;
//        if(que[i].val>b[i]) mark=false;
//        while(now>i){
//            ll tmp=que[now].val-b[now];
//            if(tmp<0) mark=false;
//            if(tmp==0){
//                now--;
//                continue;
//            }
//            if(b[i]-que[i].val>tmp){
//                que[i].val+=tmp;
//                que[now].val-=tmp;
//                ans.PB(MP(MP(que[i].id,que[now].id),tmp));
//                now--;
//            }
//            else {
//                ans.PB(MP(MP(que[i].id,que[now].id),b[i]-que[i].val));
//                que[now].val-=(b[i]-que[i].val);
//                que[i].val=b[i];
//                break;
//            }
//        }
//    }
    if(!mark) {
        puts("NO");
        return 0;
    }
    puts("YES");
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();i++){
        printf("%d %d %lld\n",ans[i].first.first,ans[i].first.second,ans[i].second);
    }

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


/*
    Author:   TelmaZzzz
    Title:    e
    Date:     2019-06-01-23.51
*/
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
//#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define PB push_back
#define MP make_pair
#define INF 1073741824
#define inf 1152921504606846976
#define pi 3.14159265358979323846
//#pragma comment(linker,"/STACK:10240000,10240000")
//mt19937 rand_(time(0));
const int N=3e5+7,M=2e6;
const long long mod=1e9+7;
inline int read(){int ret=0;char ch=getchar();bool f=1;for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');for(;isdigit(ch);ch=getchar()) ret=(ret<<1)+(ret<<3)+ch-48;return f?ret:-ret;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}//逆元
//int head[N],NEXT[M],ver[M],tot;void link(int u,int v){ver[++tot]=v;NEXT[tot]=head[u];head[u]=tot;}

struct node{
    ll val;
    int id;
}que[N];
ll b[N];
bool cmp(node a,node b){
    return a.val<b.val;
}
vector<pair<pair<int,int>,ll > >ans;
int main(){
    //freopen("1.txt","r",stdin);
    //ios::sync_with_stdio(false);
    int n;
    scanf("%d",&n);
    ll suma=0,sumb=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&que[i].val);
        que[i].id=i;
        suma+=que[i].val;
    }
    for(int i=1;i<=n;i++){
        scanf("%lld",&b[i]);
        sumb+=b[i];
    }
    if(suma!=sumb) {
        puts("NO");
        return 0;
    }
    sort(b+1,b+n+1);
    sort(que+1,que+1+n,cmp);
    int now=n;
    for(int i=1;i<=n;i++){
        if(i==now) break;
        while(1){
            ll tmp=que[now].val-b[now];
            if(b[i]-que[i].val>tmp){
                que[i].val+=tmp;
                que[now].val-=tmp;
                ans.PB(MP(MP(que[i].id,que[now].id),tmp));
                now--;
            }
            else {
                ans.PB(MP(MP(que[i].id,que[now].id),b[i]-que[i].val));
                que[now].val-=(b[i]-que[i].val);
                que[i].val=b[i];
                break;
            }
        }
    }
    puts("YES");
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();i++){
        printf("%d %d %lld\n",ans[i].first.first,ans[i].first.second,ans[i].second);
    }

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


/*
    Author:   TelmaZzzz
    Title:    e
    Date:     2019-06-01-23.51
*/
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
//#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define PB push_back
#define MP make_pair
#define INF 1073741824
#define inf 1152921504606846976
#define pi 3.14159265358979323846
//#pragma comment(linker,"/STACK:10240000,10240000")
//mt19937 rand_(time(0));
const int N=3e5+7,M=2e6;
const long long mod=1e9+7;
inline int read(){int ret=0;char ch=getchar();bool f=1;for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');for(;isdigit(ch);ch=getchar()) ret=(ret<<1)+(ret<<3)+ch-48;return f?ret:-ret;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}//逆元
//int head[N],NEXT[M],ver[M],tot;void link(int u,int v){ver[++tot]=v;NEXT[tot]=head[u];head[u]=tot;}

struct node{
    ll val;
    int id;
}que[N];
ll b[N];
bool cmp(node a,node b){
    return a.val<b.val;
}
vector<pair<pair<int,int>,ll > >ans;
int main(){
    //freopen("1.txt","r",stdin);
    //ios::sync_with_stdio(false);
    int n;
    scanf("%d",&n);
    ll suma=0,sumb=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&que[i].val);
        que[i].id=i;
        suma+=que[i].val;
    }
    for(int i=1;i<=n;i++){
        scanf("%lld",&b[i]);
        sumb+=b[i];
    }
    if(suma!=sumb) {
        puts("NO");
        return 0;
    }
    sort(b+1,b+n+1);
    sort(que+1,que+1+n,cmp);
    int now=n;
    int l=n-1,r=n;
    bool mark=true;
    while(l<=r&&l>=1){
        if(b[r]>que[r].val){
            mark=false;
            break;
        }
        if(b[l]<que[l].val){
            l--;
            continue;
        }
        if(r==l){
            mark=false;
            break;
        }
        if(b[l]==que[l].val) {
            l--;
            continue;
        }
        if(b[r]==que[r].val){
            r--;
            continue;
        }
        ll tmp=que[r].val-b[r];
        if(b[l]-que[l].val>tmp){
            que[l].val+=tmp;
            que[r].val-=tmp;
            r--;
            ans.PB(MP(MP(que[l].id,que[r].id),tmp));
        }
        else {
            ans.PB(MP(MP(que[l].id,que[r].id),b[l]-que[l].val));
            que[r].val-=(b[l]-que[l].val);
            que[l].val=b[l];
            l--;
        }
    }
    for(int i=1;i<=n;i++){
        if(que[i].val!=b[i]) mark=false;
    }
//    for(int i=n;i>=1;i--){
//        while(now>i&&que[now].val==b[now]) now--;
//        if(i==now) break;
//        if(que[i].val==b[i]) continue;
//        if(que[i].val>b[i]) mark=false;
//        while(now>i){
//            ll tmp=que[now].val-b[now];
//            if(tmp<0) mark=false;
//            if(tmp==0){
//                now--;
//                continue;
//            }
//            if(b[i]-que[i].val>tmp){
//                que[i].val+=tmp;
//                que[now].val-=tmp;
//                ans.PB(MP(MP(que[i].id,que[now].id),tmp));
//                now--;
//            }
//            else {
//                ans.PB(MP(MP(que[i].id,que[now].id),b[i]-que[i].val));
//                que[now].val-=(b[i]-que[i].val);
//                que[i].val=b[i];
//                break;
//            }
//        }
//    }
    if(!mark) {
        puts("NO");
        return 0;
    }
    puts("YES");
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();i++){
        printf("%d %d %lld\n",ans[i].first.first,ans[i].first.second,ans[i].second);
    }

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int N=300005;
struct node{
	int a,b,c;
};
vector<node> ans;
int a[N],s[N],Stack[N],top,t[N],rk[N],n;
ll pre[N];
int cmp(int x,int y){
	return s[x]<s[y];
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&s[i]),rk[i]=i;
	for (int i=1;i<=n;i++)scanf("%d",&t[i]);
	sort(rk+1,rk+n+1,cmp);sort(t+1,t+n+1);
	for (int i=1;i<=n;i++){
		pre[i]=pre[i-1]+t[i]-s[rk[i]];
		a[i]=t[i]-s[rk[i]];
		if (pre[i]<0){
			puts("NO");
			return 0;
		}
	}
	if (pre[n]){
		puts("NO");
		return 0;
	}
	for (int i=1;i<=n;i++){
		if (a[i]>0)Stack[++top]=i;
		else while(a[i]<0){
			int t=min(-a[i],a[Stack[top]]);
			ans.pb((node){rk[Stack[top]],rk[i],t});
			a[i]+=t,a[Stack[top]]-=t;
			if (!a[Stack[top]])top--;
		}
	}
	puts("YES");
	printf("%d\n",ans.size());
	for (int i=0;i<ans.size();i++)
		printf("%d %d %d\n",ans[i].a,ans[i].b,ans[i].c);
	return 0;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, P2 = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef ONLINE_JUDGE
const int N = 1e6+10;
#else
const int N = 999;
#endif

int n, c1, d1;
struct _ {
	int x,id;
	bool operator < (const _ &rhs) const {
		return x<rhs.x;
	}
} a[N], b[N], c[N], d[N];
int p1[N],p2[N],p3[N],cnt,f[N];
void add(int x, int y, int v) {
	++cnt;
	if (f[x]>f[y]) swap(x,y);
	p1[cnt]=x,p2[cnt]=y,p3[cnt]=v;
}
int main() {
	scanf("%d", &n);
	int s1=0,s2=0;
	REP(i,1,n) {
		scanf("%d",&a[i].x),a[i].id=i,s1+=a[i].x;
		f[i]=a[i].x;
	}
	REP(i,1,n) scanf("%d",&b[i].x),b[i].id=i,s2+=b[i].x;
	if (s1!=s2) return puts("NO"),0;
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	if (a[n].x<b[n].x||a[1].x>b[1].x) return puts("NO"),0;
	puts("YES");
	REP(i,1,n) {
		if (a[i].x<b[i].x) c[++c1]={b[i].x-a[i].x,a[i].id};
		else if (a[i].x>b[i].x) d[++d1]={a[i].x-b[i].x,a[i].id};
	}
	sort(c+1,c+1+c1);
	sort(d+1,d+1+d1);
	int now = c1;
	PER(i,1,d1) {
		while (now>=1&&c[now].x<=d[i].x) {
			add(d[i].id,c[now].id,c[now].x);
			d[i].x-=c[now].x, --now;
		}
		if (!d[i].x) continue;
		add(d[i].id,c[now].id,d[i].x);
		c[now].x -= d[i].x;
	}
	printf("%d\n",cnt);
	REP(i,1,cnt) printf("%d %d %d\n",p1[i],p2[i],p3[i]);
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, P2 = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef ONLINE_JUDGE
const int N = 1e6+10;
#else
const int N = 999;
#endif

int n, c1, d1;
struct _ {
	int x,id;
	bool operator < (const _ &rhs) const {
		return x<rhs.x;
	}
} a[N], b[N], c[N], d[N];
int p1[N],p2[N],p3[N],cnt,f[N];
void add(int x, int y, int v) {
	++cnt;
	if (f[x]>f[y]) swap(x,y);
	p1[cnt]=x,p2[cnt]=y,p3[cnt]=v;
}
int main() {
	scanf("%d", &n);
	ll s1=0,s2=0;
	REP(i,1,n) {
		scanf("%d",&a[i].x),a[i].id=i,s1+=a[i].x;
		f[i]=a[i].x;
	}
	REP(i,1,n) scanf("%d",&b[i].x),b[i].id=i,s2+=b[i].x;
	if (s1!=s2) return puts("NO"),0;
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	if (a[n].x<b[n].x||a[1].x>b[1].x) return puts("NO"),0;
	puts("YES");
	REP(i,1,n) {
		if (a[i].x<b[i].x) c[++c1]={b[i].x-a[i].x,a[i].id};
		else if (a[i].x>b[i].x) d[++d1]={a[i].x-b[i].x,a[i].id};
	}
	int now = c1;
	PER(i,1,d1) {
		while (now>=1&&c[now].x<=d[i].x) {
			add(d[i].id,c[now].id,c[now].x);
			d[i].x-=c[now].x, --now;
		}
		if (!d[i].x) continue;
		add(d[i].id,c[now].id,d[i].x);
		c[now].x -= d[i].x;
	}
	printf("%d\n",cnt);
	REP(i,1,cnt) printf("%d %d %d\n",p1[i],p2[i],p3[i]);
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, P2 = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef ONLINE_JUDGE
const int N = 1e6+10;
#else
const int N = 999;
#endif

int n, c1, d1;
struct _ {
	int x,id;
	bool operator < (const _ &rhs) const {
		return x<rhs.x;
	}
} a[N], b[N], c[N], d[N];
int p1[N],p2[N],p3[N],cnt,f[N];
void add(int x, int y, int v) {
	++cnt;
	if (f[x]>f[y]) swap(x,y);
	p1[cnt]=x,p2[cnt]=y,p3[cnt]=v;
}
int main() {
	scanf("%d", &n);
	ll s1=0,s2=0;
	REP(i,1,n) {
		scanf("%d",&a[i].x),a[i].id=i,s1+=a[i].x;
		f[i]=a[i].x;
	}
	REP(i,1,n) scanf("%d",&b[i].x),b[i].id=i,s2+=b[i].x;
	if (s1!=s2) return puts("NO"),0;
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	if (a[n].x<b[n].x||a[1].x>b[1].x) return puts("NO"),0;
	puts("YES");
	REP(i,1,n) {
		if (a[i].x<b[i].x) c[++c1]={b[i].x-a[i].x,a[i].id};
		else if (a[i].x>b[i].x) d[++d1]={a[i].x-b[i].x,a[i].id};
	}
	sort(c+1,c+1+c1);
	sort(d+1,d+1+d1);
	int now = c1;
	PER(i,1,d1) {
		while (now>=1&&c[now].x<=d[i].x) {
			add(d[i].id,c[now].id,c[now].x);
			d[i].x-=c[now].x, --now;
		}
		if (!d[i].x) continue;
		add(d[i].id,c[now].id,d[i].x);
		c[now].x -= d[i].x;
	}
	printf("%d\n",cnt);
	REP(i,1,cnt) printf("%d %d %d\n",p1[i],p2[i],p3[i]);
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, P2 = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef ONLINE_JUDGE
const int N = 1e6+10;
#else
const int N = 999;
#endif

int n, c1, d1;
struct _ {
	int x,id;
	bool operator < (const _ &rhs) const {
		return x<rhs.x;
	}
} a[N], b[N], c[N], d[N];
int p1[N],p2[N],p3[N],cnt;
void add(int x, int y, int v) {
	++cnt;
	p1[cnt]=x,p2[cnt]=y,p3[cnt]=v;
}
int main() {
	scanf("%d", &n);
	int s1=0,s2=0;
	REP(i,1,n) scanf("%d",&a[i].x),a[i].id=i,s1+=a[i].x;
	REP(i,1,n) scanf("%d",&b[i].x),b[i].id=i,s2+=b[i].x;
	if (s1!=s2) return puts("NO"),0;
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	if (a[n].x<b[n].x||a[1].x>b[1].x) return puts("NO"),0;
	puts("YES");
	REP(i,1,n) {
		if (a[i].x<b[i].x) c[++c1]={b[i].x-a[i].x,a[i].id};
		else if (a[i].x>b[i].x) d[++d1]={a[i].x-b[i].x,a[i].id};
	}
	sort(c+1,c+1+c1);
	sort(d+1,d+1+d1);
	int now = c1;
	PER(i,1,d1) {
		while (now>=1&&c[now].x<=d[i].x) {
			add(d[i].id,c[now].id,c[now].x);
			d[i].x-=c[now].x, --now;
		}
		if (!d[i].x) continue;
		add(d[i].id,c[now].id,d[i].x);
		c[now].x -= d[i].x;
	}
	printf("%d\n",cnt);
	REP(i,1,cnt) printf("%d %d %d\n",p1[i],p2[i],p3[i]);
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, P2 = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef ONLINE_JUDGE
const int N = 1e6+10;
#else
const int N = 999;
#endif

int n, c1, d1;
struct _ {
	int x,id;
	bool operator < (const _ &rhs) const {
		return x<rhs.x;
	}
	void pr() {
		printf("x=%d,id=%d\n",x,id);
	}
} a[N], b[N], c[N], d[N];
int p1[N],p2[N],p3[N],cnt,f[N];
void add(int x, int y, int v) {
	++cnt;
	if (f[x]>f[y]) puts("NO"),exit(0);
	p1[cnt]=x,p2[cnt]=y,p3[cnt]=v;
}
int main() {
	scanf("%d", &n);
	ll s1=0,s2=0;
	REP(i,1,n) {
		scanf("%d",&a[i].x),a[i].id=i,s1+=a[i].x;
		f[i]=a[i].x;
	}
	REP(i,1,n) scanf("%d",&b[i].x),b[i].id=i,s2+=b[i].x;
	if (s1!=s2) return puts("NO"),0;
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	REP(i,1,n) {
		if (a[i].x<b[i].x) c[++c1]={b[i].x-a[i].x,a[i].id};
		else if (a[i].x>b[i].x) d[++d1]={a[i].x-b[i].x,a[i].id};
	}
	sort(d+1,d+1+n,[](_ x,_ y){return f[x.id]>f[y.id];});
	sort(c+1,c+1+n,[](_ x,_ y){return f[x.id]>f[y.id];});
	int now = 1;
	REP(i,1,n) {
		while (c[now].x<=d[i].x) {
			add(c[now].id,d[i].id,c[now].x);
			d[i].x-=c[now].x, ++now;
		}
		if (d[i].x) {
			add(c[now].id,d[i].id,d[i].x);
			c[now].x-=d[i].x;
		}
	}
	printf("%d\n",cnt);
	REP(i,1,n) printf("%d %d %d\n",p1[i],p2[i],p3[i]);
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, P2 = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef ONLINE_JUDGE
const int N = 1e6+10;
#else
const int N = 999;
#endif

int n, c1, d1;
struct _ {
	int x,id;
	bool operator < (const _ &rhs) const {
		return x<rhs.x;
	}
} a[N], b[N], c[N], d[N];
int p1[N],p2[N],p3[N],cnt,f[N];
void add(int x, int y, int v) {
	++cnt;
	if (f[x]>f[y]) swap(x,y);
	p1[cnt]=x,p2[cnt]=y,p3[cnt]=v;
}
int main() {
	scanf("%d", &n);
	ll s1=0,s2=0;
	REP(i,1,n) {
		scanf("%d",&a[i].x),a[i].id=i,s1+=a[i].x;
		f[i]=a[i].x;
	}
	REP(i,1,n) scanf("%d",&b[i].x),b[i].id=i,s2+=b[i].x;
	if (s1!=s2) return puts("NO"),0;
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	if (a[n].x<b[n].x||a[1].x>b[1].x) return puts("NO"),0;
	REP(i,1,n) {
		if (a[i].x<b[i].x) c[++c1]={b[i].x-a[i].x,a[i].id};
		else if (a[i].x>b[i].x) d[++d1]={a[i].x-b[i].x,a[i].id};
	}
	int now = c1;
	PER(i,1,d1) {
		while (now>=1&&c[now].x<=d[i].x) {
			add(d[i].id,c[now].id,c[now].x);
			d[i].x-=c[now].x, --now;
		}
		if (!d[i].x) continue;
		add(d[i].id,c[now].id,d[i].x);
		c[now].x -= d[i].x;
	}
	if (now>1||c[now].x) return puts("NO"),0;
	puts("YES");
	printf("%d\n",cnt);
	REP(i,1,cnt) printf("%d %d %d\n",p1[i],p2[i],p3[i]);
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, P2 = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef ONLINE_JUDGE
const int N = 1e6+10;
#else
const int N = 999;
#endif

int n, c1, d1;
struct _ {
	int x,id;
	bool operator < (const _ &rhs) const {
		return x<rhs.x;
	}
	void pr() {
		printf("x=%d,id=%d\n",x,id);
	}
} a[N], b[N], c[N], d[N];
int p1[N],p2[N],p3[N],cnt,f[N];
void add(int x, int y, int v) {
	++cnt;
	if (f[x]>f[y]) puts("NO"),exit(0);
	p1[cnt]=x,p2[cnt]=y,p3[cnt]=v;
}
int main() {
	scanf("%d", &n);
	ll s1=0,s2=0;
	REP(i,1,n) {
		scanf("%d",&a[i].x),a[i].id=i,s1+=a[i].x;
		f[i]=a[i].x;
	}
	REP(i,1,n) scanf("%d",&b[i].x),b[i].id=i,s2+=b[i].x;
	if (s1!=s2) return puts("NO"),0;
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	REP(i,1,n) {
		if (a[i].x<b[i].x) c[++c1]={b[i].x-a[i].x,a[i].id};
		else if (a[i].x>b[i].x) d[++d1]={a[i].x-b[i].x,a[i].id};
	}
	sort(d+1,d+1+d1,[](_ x,_ y){return f[x.id]>f[y.id];});
	sort(c+1,c+1+c1,[](_ x,_ y){return f[x.id]>f[y.id];});
	int now = 1;
	REP(i,1,d1) {
		while (now<=c1&&c[now].x<=d[i].x) {
			add(c[now].id,d[i].id,c[now].x);
			d[i].x-=c[now].x, ++now;
		}
		if (d[i].x) {
			add(c[now].id,d[i].id,d[i].x);
			c[now].x-=d[i].x;
		}
	}
	puts("YES");
	printf("%d\n",cnt);
	REP(i,1,cnt) printf("%d %d %d\n",p1[i],p2[i],p3[i]);
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, P2 = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef ONLINE_JUDGE
const int N = 1e6+10;
#else
const int N = 999;
#endif

int n, c1, d1;
struct _ {
	int x,id;
	bool operator < (const _ &rhs) const {
		return x<rhs.x;
	}
} a[N], b[N], c[N], d[N];
int p1[N],p2[N],p3[N],cnt,f[N];
void add(int x, int y, int v) {
	++cnt;
	if (f[x]>f[y]) swap(x,y);
	p1[cnt]=x,p2[cnt]=y,p3[cnt]=v;
}
int main() {
	scanf("%d", &n);
	ll s1=0,s2=0;
	REP(i,1,n) {
		scanf("%d",&a[i].x),a[i].id=i,s1+=a[i].x;
		f[i]=a[i].x;
	}
	REP(i,1,n) scanf("%d",&b[i].x),b[i].id=i,s2+=b[i].x;
	if (s1!=s2) return puts("NO"),0;
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	if (a[n].x<b[n].x||a[1].x>b[1].x) return puts("NO"),0;
	REP(i,1,n) {
		if (a[i].x<b[i].x) c[++c1]={b[i].x-a[i].x,a[i].id};
		else if (a[i].x>b[i].x) d[++d1]={a[i].x-b[i].x,a[i].id};
	}
	int now = c1;
	PER(i,1,d1) {
		while (now>=1&&c[now].x<=d[i].x) {
			add(d[i].id,c[now].id,c[now].x);
			d[i].x-=c[now].x, --now;
		}
		if (!d[i].x) continue;
		add(d[i].id,c[now].id,d[i].x);
		c[now].x -= d[i].x;
	}
	if (now!=1||c[now].x) return puts("NO"),0;
	puts("YES");
	printf("%d\n",cnt);
	REP(i,1,cnt) printf("%d %d %d\n",p1[i],p2[i],p3[i]);
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, P2 = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef ONLINE_JUDGE
const int N = 1e6+10;
#else
const int N = 999;
#endif

int n, c1, d1;
struct _ {
	int x,id;
	bool operator < (const _ &rhs) const {
		return x<rhs.x;
	}
	void pr() {
		printf("x=%d,id=%d\n",x,id);
	}
} a[N], b[N], c[N], d[N];
int p1[N],p2[N],p3[N],cnt,f[N];
void add(int x, int y, int v) {
	++cnt;
	if (f[x]>f[y]) puts("NO"),exit(0);
	p1[cnt]=x,p2[cnt]=y,p3[cnt]=v;
	f[x]+=v,f[y]-=v;
}
int main() {
	scanf("%d", &n);
	ll s1=0,s2=0;
	REP(i,1,n) {
		scanf("%d",&a[i].x),a[i].id=i,s1+=a[i].x;
		f[i]=a[i].x;
	}
	REP(i,1,n) scanf("%d",&b[i].x),b[i].id=i,s2+=b[i].x;
	if (s1!=s2) return puts("NO"),0;
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	REP(i,1,n) {
		if (a[i].x<b[i].x) c[++c1]={b[i].x-a[i].x,a[i].id};
		else if (a[i].x>b[i].x) d[++d1]={a[i].x-b[i].x,a[i].id};
	}
	sort(d+1,d+1+d1,[](_ x,_ y){return f[x.id]>f[y.id];});
	sort(c+1,c+1+c1,[](_ x,_ y){return f[x.id]>f[y.id];});
	int now = 1;
	REP(i,1,d1) {
		while (now<=c1&&c[now].x<=d[i].x) {
			add(c[now].id,d[i].id,c[now].x);
			d[i].x-=c[now].x, ++now;
		}
		if (d[i].x) {
			add(c[now].id,d[i].id,d[i].x);
			c[now].x-=d[i].x;
		}
	}
	puts("YES");
	printf("%d\n",cnt);
	REP(i,1,cnt) printf("%d %d %d\n",p1[i],p2[i],p3[i]);
}


#include<bits/stdc++.h>
using namespace std;
long long read()
{
	char ch=getchar();long long x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-ff;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
void write(long long aa)
{
	if(aa<0) putchar('-'),aa=-aa;
	if(aa>9) write(aa/10);
	putchar(aa%10+'0');
	return;
}
long long n,sum,cnt;
long long s[300005],t[300005],id[300005];
long long l[3000005],r[3000005],d[3000005];
bool cmp(long long aa,long long bb) {return t[aa]==t[bb]?s[aa]>s[bb]:t[aa]>t[bb];}
int main()
{
	n=read();
	for(long long i=1;i<=n;++i) s[i]=read(),sum+=s[i];
	for(long long i=1;i<=n;++i) t[i]=read(),id[i]=i,sum-=t[i];
	if(sum!=0) {puts("NO");return 0;}
	sort(id+1,id+n+1,cmp);
	long long now=1;
	for(long long i=1;i<=n;++i)
	{
		if(s[id[i]]==t[id[i]]) continue;
		if(s[id[i]]<t[id[i]]) {puts("NO");return 0;}
		long long tmp=s[id[i]]-t[id[i]];
		now=max(i+1,now);
		while(tmp)
		{
			while(s[id[now]]>=t[id[now]]) now++;
			if(tmp<=t[id[now]]-s[id[now]]) s[id[now]]+=tmp,l[++cnt]=id[now],r[cnt]=id[i],d[cnt]=tmp;
			else l[++cnt]=id[now],r[cnt]=id[i],d[cnt]=t[id[now]]-s[id[now]],s[id[now]]=t[id[now]];
			now++;tmp-=d[cnt];
		}
	}
	puts("YES");
	write(cnt);puts("");
	for(long long i=1;i<=cnt;++i) write(l[i]),putchar(' '),write(r[i]),putchar(' '),write(d[i]),puts("");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long read()
{
	char ch=getchar();long long x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-ff;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
void write(long long aa)
{
	if(aa<0) putchar('-'),aa=-aa;
	if(aa>9) write(aa/10);
	putchar(aa%10+'0');
	return;
}
long long n,sum,cnt,nb;
long long s[300005],t[300005],id[300005],b[300005];
long long l[3000005],r[3000005],d[3000005];
struct node {int x;};
bool operator <(node aa,node bb) {return s[aa.x]<s[bb.x];}
bool cmp(int aa,int bb) {return t[aa]>t[bb];}
priority_queue<node>q;
void gao(int aa,int bb)
{
	int tmp=min((s[aa]-s[bb])/2,min(s[aa]-t[aa],t[bb]-s[bb]));
	s[aa]-=tmp;s[bb]+=tmp;
	l[++cnt]=aa;r[cnt]=bb;d[cnt]=tmp;
	if(s[aa]!=t[aa]) q.push((node){aa});
	return;
}
int main()
{
	n=read();
	for(long long i=1;i<=n;++i) s[i]=read(),sum+=s[i];
	for(long long i=1;i<=n;++i) t[i]=read(),sum-=t[i];
	if(sum!=0) {puts("NO");return 0;}
	for(int i=1;i<=n;++i)
	if(s[i]>t[i]) q.push((node){i});
	else if(t[i]>s[i]) b[++nb]=i;
	sort(b+1,b+nb+1,cmp);
	for(int i=1;i<=nb;++i)
	{
		while(s[b[i]]<t[b[i]])
		{
			int kk=q.top().x;q.pop();
			if(s[kk]<=t[b[i]]) {puts("NO");return 0;}
			gao(kk,b[i]);
		}
	}
	puts("YES");
	write(cnt);puts("");
	for(long long i=1;i<=cnt;++i) write(l[i]),putchar(' '),write(r[i]),putchar(' '),write(d[i]),puts("");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long read()
{
	char ch=getchar();long long x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-ff;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
void write(long long aa)
{
	if(aa<0) putchar('-'),aa=-aa;
	if(aa>9) write(aa/10);
	putchar(aa%10+'0');
	return;
}
long long n,sum,cnt,nb;
long long s[300005],t[300005],id[300005],b[300005];
long long l[3000005],r[3000005],d[3000005];
struct node {int x;};
bool operator <(node aa,node bb) {return s[aa.x]<s[bb.x];}
bool cmp(int aa,int bb) {return t[aa]>t[bb];}
priority_queue<node>q;
void gao(int aa,int bb)
{
	int tmp=min((s[aa]-s[bb])/2,min(s[aa]-t[aa],t[bb]-s[bb]));
	s[aa]-=tmp;s[bb]+=tmp;
	l[++cnt]=bb;r[cnt]=aa;d[cnt]=tmp;
	if(s[aa]!=t[aa]) q.push((node){aa});
	return;
}
int main()
{
	n=read();
	for(long long i=1;i<=n;++i) s[i]=read(),sum+=s[i];
	for(long long i=1;i<=n;++i) t[i]=read(),sum-=t[i];
	if(sum!=0) {puts("NO");return 0;}
	for(int i=1;i<=n;++i)
	if(s[i]>t[i]) q.push((node){i});
	else if(t[i]>s[i]) b[++nb]=i;
	sort(b+1,b+nb+1,cmp);
	for(int i=1;i<=nb;++i)
	{
		while(s[b[i]]<t[b[i]])
		{
			int kk=q.top().x;q.pop();
			if(s[kk]<=t[b[i]]) {puts("NO");return 0;}
			gao(kk,b[i]);
		}
	}
	puts("YES");
	write(cnt);puts("");
	for(long long i=1;i<=cnt;++i) write(l[i]),putchar(' '),write(r[i]),putchar(' '),write(d[i]),puts("");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long read()
{
	char ch=getchar();long long x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-ff;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
void write(long long aa)
{
	if(aa<0) putchar('-'),aa=-aa;
	if(aa>9) write(aa/10);
	putchar(aa%10+'0');
	return;
}
long long n,sum,cnt,nb;
long long l[3000005],r[3000005],d[3000005];
struct node
{
	long long val,id;
}s[300005],t[300005];
bool operator <(node aa,node bb) {return aa.val<bb.val;}
bool cmp(node aa,node bb) {return bb<aa;}
priority_queue<node>q;
int main()
{
	n=read();
	for(long long i=1;i<=n;++i) s[i].val=read(),s[i].id=i,sum+=s[i].val;
	for(long long i=1;i<=n;++i) t[i].val=read(),t[i].id=i,sum-=t[i].val;
	if(sum!=0) {puts("NO");return 0;}
	sort(s+1,s+n+1,cmp);
	sort(t+1,t+n+1,cmp);
	for(long long i=1;i<=n;++i)
	{
		long long tmp=s[i].val-t[i].val;
		if(tmp>0) q.push((node){tmp,s[i].id});
		else if(tmp<0)
		{
			tmp=-tmp;
			while(tmp)
			{
				if(q.empty()) {puts("NO");return 0;}
				node kk=q.top();q.pop();
				long long qwq=min(tmp,kk.val);
				l[++cnt]=s[i].id,r[cnt]=kk.id,d[cnt]=qwq;
				tmp-=qwq;kk.val-=qwq;
				if(kk.val) q.push(kk);
			}
		}
	}
	puts("YES");
	write(cnt);puts("");
	for(long long i=1;i<=cnt;++i) write(l[i]),putchar(' '),write(r[i]),putchar(' '),write(d[i]),puts("");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long read()
{
	char ch=getchar();long long x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-ff;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
void write(long long aa)
{
	if(aa<0) putchar('-'),aa=-aa;
	if(aa>9) write(aa/10);
	putchar(aa%10+'0');
	return;
}
long long n,sum,cnt,nb;
long long s[300005],t[300005],id[300005],b[300005];
long long l[3000005],r[3000005],d[3000005];
struct node {int x;};
bool operator <(node aa,node bb) {return s[aa.x]>s[bb.x];}
bool cmp(int aa,int bb) {return t[aa]==t[bb]?s[aa]<s[bb]:t[aa]>t[bb];}
priority_queue<node>q;
void gao(int aa,int bb)
{
	int tmp=min((s[aa]-s[bb])/2,min(s[aa]-t[aa],t[bb]-s[bb]));
	s[aa]-=tmp;s[bb]+=tmp;
	l[++cnt]=bb;r[cnt]=aa;d[cnt]=tmp;
	if(s[aa]!=t[aa]) q.push((node){aa});
	return;
}
int main()
{
	n=read();
	for(long long i=1;i<=n;++i) s[i]=read(),sum+=s[i];
	for(long long i=1;i<=n;++i) t[i]=read(),sum-=t[i];
	if(sum!=0) {puts("NO");return 0;}
	for(int i=1;i<=n;++i)
	if(s[i]>t[i]) q.push((node){i});
	else if(t[i]>s[i]) b[++nb]=i;
	sort(b+1,b+nb+1,cmp);
	for(int i=1;i<=nb;++i)
	{
		while(s[b[i]]<t[b[i]])
		{
			int kk=q.top().x;q.pop();
			if(s[kk]<=t[b[i]]) {puts("NO");return 0;}
			gao(kk,b[i]);
		}
	}
	puts("YES");
	write(cnt);puts("");
	for(long long i=1;i<=cnt;++i) write(l[i]),putchar(' '),write(r[i]),putchar(' '),write(d[i]),puts("");
	return 0;
}


#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=300000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n,val[N];
bool cmp(pii x,pii y) {return val[x.sec]>val[y.sec];}
struct ansnode{int x,y,d;};
vector<ansnode> ans;
vector<pii> l,r;
pii a[N],b[N];

void ask(int x,int y,int d)
{
    //cout << "ask " << x << " " << y << " "  << d << endl;
    if (val[x]<val[y]) {puts("NO");exit(0);}
    val[x]+=d;val[y]-=d;
    ans.pb((ansnode){x,y,d});
}

int main()
{
    n=read();
    rep(i,1,n) a[i]=mkp(read(),i);
    rep(i,1,n) b[i]=mkp(read(),i);
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
    rep(i,1,n)
    {
        if (a[i].fir<b[i].fir) r.pb(mkp(b[i].fir-a[i].fir,a[i].sec));
        else l.pb(mkp(a[i].fir-b[i].fir,a[i].sec));
        val[a[i].sec]=a[i].fir;
    }
    sort(l.begin(),l.end(),cmp);
    sort(r.begin(),r.end(),cmp);
    int len1=l.size(),len2=r.size();
    int nowr=0;
    //rep(i,0,len1-1) cout << l[i].fir << " " << l[i].sec << endl;
    //cout << endl;
    //rep(i,0,len2-1) cout << r[i].fir << " " << r[i].sec << endl;
    rep(i,0,len1-1)
    {
        while ((nowr<len2) && (r[nowr].fir<l[i].fir))
        {
            ask(l[i].sec,r[nowr].sec,r[nowr].fir);
            l[i].fir-=r[nowr].fir;nowr++;
        }
        if ((l[i].fir) && (nowr==len2)) {puts("NO");return 0;}
        //cout << 'a' << endl;
        ask(l[i].sec,r[nowr].sec,l[i].fir);
        r[nowr].fir-=l[i].fir;
        if (!r[nowr].fir) nowr++;
        //cout << "nowr=" << nowr << endl;
    }
    if (nowr!=len2) {puts("NO");return 0;}
    int len=ans.size();
    printf("YES\n%d\n",len);
    rep(i,0,len-1) printf("%d %d %d\n",ans[i].y,ans[i].x,ans[i].d);
    return 0;
}


#include <string>
#include <string.h>
#include <cstdio>
#include <iostream>
#include <memory>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cassert>

using namespace std;

#if ( _WIN32 || __WIN32__ || _WIN64 || __WIN64__ )
#define I64 "%I64d"
#else
#define I64 "%Ld"
#endif

#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define dbg(x) cerr << #x << " = " << (x) << endl
#define fori(i,b,e) for(int i = (b); i < (e); i++)
#define forall(p,s) for(typeof((s).begin()) p = (s).begin(); p != (s).end(); p++)
#define memclr(a) memset((a), 0, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define fi first
#define se second

typedef long double ldb;
typedef long long int64;
typedef pair<int, int> pii;
const int inf = (int)1e9;

#define PROBLEM_NAME "D"

int n;
const int maxn = 300100;
int a[maxn];
bool was[maxn];
int num[maxn], team[maxn][3];

int main () {
//	freopen (PROBLEM_NAME ".in", "rt", stdin);
//	freopen (PROBLEM_NAME ".out", "wt", stdout);
	scanf ("%d", &n);

	fori(i,0,n*3) {
		scanf ("%d", a+i);
		a[i]--;
	}
	fori(i,0,n) {
		fori(j,0,3) {
			scanf ("%d", team[i]+j);
			team[i][j]--;
			num[team[i][j]] = i;
		}
	}
	int k;
	scanf ("%d", &k);
	k--;
	fori(i,0,n*3) {
		if (a[i] == k && !was[k]) {
			fori(j,0,3) {
				int val = team[num[a[i]]][j];
				was[val] = true;
			}
			break;
		} else {
			fori(j,0,3) {
				was[team[num[a[i]]][j]] = true;
			}
		}
	}
	fori(i,0,n*3) {
		if (was[i] && i != k) {
			printf ("%d ", i+1);
		}
	}
	fori(i,0,n*3) {
		if (!was[i]) {
			printf ("%d ", i+1);
		}
	}
	return 0;
}


#include <string>
#include <string.h>
#include <cstdio>
#include <iostream>
#include <memory>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cassert>

using namespace std;

#if ( _WIN32 || __WIN32__ || _WIN64 || __WIN64__ )
#define I64 "%I64d"
#else
#define I64 "%Ld"
#endif

#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define dbg(x) cerr << #x << " = " << (x) << endl
#define fori(i,b,e) for(int i = (b); i < (e); i++)
#define forall(p,s) for(typeof((s).begin()) p = (s).begin(); p != (s).end(); p++)
#define memclr(a) memset((a), 0, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define fi first
#define se second

typedef long double ldb;
typedef long long int64;
typedef pair<int, int> pii;
const int inf = (int)1e9;

#define PROBLEM_NAME "D"

int n;
const int maxn = 300100;
int a[maxn];
bool was[maxn];
int num[maxn], team[maxn][3];

int main () {
//	freopen (PROBLEM_NAME ".in", "rt", stdin);
//	freopen (PROBLEM_NAME ".out", "wt", stdout);
	scanf ("%d", &n);

	fori(i,0,n*3) {
		scanf ("%d", a+i);
		a[i]--;
	}
	fori(i,0,n) {
		fori(j,0,3) {
			scanf ("%d", team[i]+j);
			team[i][j]--;
			num[team[i][j]] = i;
		}
	}
	int k;
	scanf ("%d", &k);
	k--;
	was[k] = true;
	fori(i,0,n*3) {
		if (a[i] == k) {
			fori(j,0,3) {
				int val = team[num[a[i]]][j];
				was[val] = true;
			}
			break;
		} else {
			fori(j,0,3) {
				was[team[num[a[i]]][j]] = true;
			}
		}
	}
	fori(i,0,n*3) {
		if (was[i] && i != k) {
			printf ("%d ", i+1);
		}
	}
	fori(i,0,n*3) {
		if (!was[i]) {
			printf ("%d ", i+1);
		}
	}
	return 0;
}


#include <string>
#include <string.h>
#include <cstdio>
#include <iostream>
#include <memory>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cassert>

using namespace std;

#if ( _WIN32 || __WIN32__ || _WIN64 || __WIN64__ )
#define I64 "%I64d"
#else
#define I64 "%Ld"
#endif

#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define dbg(x) cerr << #x << " = " << (x) << endl
#define fori(i,b,e) for(int i = (b); i < (e); i++)
#define forall(p,s) for(typeof((s).begin()) p = (s).begin(); p != (s).end(); p++)
#define memclr(a) memset((a), 0, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define fi first
#define se second

typedef long double ldb;
typedef long long int64;
typedef pair<int, int> pii;
const int inf = (int)1e9;

#define PROBLEM_NAME "D"

int n;
const int maxn = 300100;
int a[maxn];
bool was[maxn];
int num[maxn], team[maxn/3][3];
int res[maxn];

vector<int> move;

int main () {
//	freopen (PROBLEM_NAME ".in", "rt", stdin);
//	freopen (PROBLEM_NAME ".out", "wt", stdout);
	scanf ("%d", &n);

	fori(i,0,n*3) {
		scanf ("%d", a+i);
		a[i]--;
	}
	fori(i,0,n) {
		fori(j,0,3) {
			scanf ("%d", team[i]+j);
			team[i][j]--;
			num[team[i][j]] = i;
		}
	}
	int k;
	scanf ("%d", &k);
	k--;
	int f[2];
	f[0] = f[1] = -1;
	fori(i,0,n*3) {
		if (a[i] == k && !was[k]) {

			fori(j,0,3) {
				int val = team[num[a[i]]][j];
				was[val] = true;
				if (val != k) {
					if (f[0] == -1) {
						f[0] = val;
					} else {
						f[1] = val;
					}
				}
			}
			break;
		} else {
			fori(j,0,3) {
				was[team[num[a[i]]][j]] = true;
			}
		}
	}
	sort(f,f+2);
	fori(i,0,k) {
		res[i] = i;
	}
	fori(i,k+1,n*3) {
		res[i-1] = i;
	}
	if (f[0] == -1) {
		fori(i,0,n*3-1) {
			printf ("%d ", res[i]+1);
		}
		return 0;
	}
	fori(i,0,n*3) {
		if (was[i] && i != k) {
			printf ("%d ", i+1);
		}
	}
	fori(i,0,n*3) {
		if (!was[i]) {
			printf ("%d ", i+1);
		}
	}
	int m = 3*n-1;
	fori(s,0,2) {
		int v = f[s];
		move.clear();
		int cur = 0;
		fori(i,0,m) {
			if (!was[res[i]]) {
				move.pb(res[i]);
			} else {
				res[cur] = res[i];
				cur++;
				if (res[i] == v) {
					break;
				}
			}
		}
		fori(i,0,sz(move)) {
			res[cur++] = move[i];
		}
	}
	return 0;
}


#include <cstdio>

const int N = 100000 + 1;

int n;
int a[N * 3];
int rank[N * 3];
int b[N][3], top[N];
int f[N * 3];
int k;
bool del[N * 3];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= 3 * n; i++){
		scanf("%d", &a[i]);
		rank[a[i]] = i;
	}
	for(int i = 1; i <= n; i++){
		top[i] = a[3 * n];
		for(int j = 0; j < 3; j++){
			scanf("%d", &b[i][j]);
			if (rank[b[i][j]] < rank[top[i]]) top[i] = b[i][j];
		}
		for(int j = 0; j < 3; j++) f[b[i][j]] = top[i];
	}
	scanf("%d", &k);
	if (f[k] != k) {
		for(int i = 1; i <= 3 * n; i++){
			if (i == k) continue;
			printf("%d ", i);
		}
		puts("");
		return 0;
	}
	for(int i = 1; i <= 3 * n; i++){
		if (i == k) continue;
		if (rank[f[i]] <= rank[f[k]]) printf("%d ", i);
		else del[i] = true;
	}
	for(int i = 1; i <= 3 * n; i++){
		if (i == k) continue;
		if (!del[i]) continue;
		printf("%d ", i);
	}
	puts("");
}


#include <cstdio>

const int N = 100000 + 1;

int n;
int a[N * 3];
int rank[N * 3];
int b[N][3], top[N];
int id[N * 3];
int k;
bool del[N * 3];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= 3 * n; i++){
		scanf("%d", &a[i]);
		rank[a[i]] = i;
	}
	for(int i = 1; i <= n; i++){
		top[i] = a[3 * n];
		for(int j = 0; j < 3; j++){
			scanf("%d", &b[i][j]);
			id[b[i][j]] = i;
			if (rank[b[i][j]] < rank[top[i]]) top[i] = b[i][j];
		}
	}
	scanf("%d", &k);
	if (top[id[k]] != k){
		for(int i = 1; i <= 3 * n; i++){
			if (i == k) continue;
			printf("%d ", i);
		}
		puts("");
		return 0;
	}
	int up = 0;
	for(int i = 1; i <= 3 * n; i++){
		if (i == k) continue;
		if (id[i] != id[k]) continue;
		if (i > up) up = i;
	}
	for(int i = 1; i <= up; i++){
		if (i == k) continue;
		if (rank[top[id[i]]] <= rank[top[id[k]]]){
			del[i] = true;
			printf("%d ", i);
		}
	}
	for(int i = 1; i <= 3 * n; i++){
		if (i == k) continue;
		if (del[i]) continue;
		printf("%d ", i);
	}
	puts("");
}


#include <cstdio>

const int N = 100000 + 1;

int n;
int a[N * 3];
int rank[N * 3];
int b[N][3], top[N];
int f[N * 3];
int k;
bool del[N * 3];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= 3 * n; i++){
		scanf("%d", &a[i]);
		rank[a[i]] = i;
	}
	for(int i = 1; i <= n; i++){
		top[i] = a[n];
		for(int j = 0; j < 3; j++){
			scanf("%d", &b[i][j]);
			if (rank[b[i][j]] < rank[top[i]]) top[i] = b[i][j];
		}
		for(int j = 0; j < 3; j++) f[b[i][j]] = top[i];
	}
	scanf("%d", &k);
	if (f[k] != k) {
		for(int i = 1; i <= 3 * n; i++){
			if (i == k) continue;
			printf("%d ", i);
		}
		puts("");
		return 0;
	}
	for(int i = 1; i <= 3 * n; i++){
		if (i == k) continue;
		if (rank[f[i]] <= rank[f[k]]) printf("%d ", i);
		else del[i] = true;
	}
	for(int i = 1; i <= 3 * n; i++){
		if (i == k) continue;
		if (!del[i]) continue;
		printf("%d ", i);
	}
	puts("");
}