#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define x first
#define y second
#define bg begin()
#define ed end()
#define pb push_back
#define mp make_pair
#define sz(a) int((a).size())
#define R(i,n) for(int i(0);i<(n);++i)
#define L(i,n) for(int i((n)-1);i>=0;--i)
const int iinf=0x3f3f3f3f;
const ll linf=0x3f3f3f3f3f3f3f3f;

//Data
const int N=2e5;
int n,a[N],b[N],p[N],q[N],o[N];
vector<pair<int,int>> ns;

//Function

//Main
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>n;
    R(i,n) cin>>a[i],o[i]=i;
    R(i,n) cin>>b[i];
    R(i,n) cin>>p[i],q[--p[i]]=i;
    R(i,n)if(i!=p[i]&&a[i]<=b[p[i]])
        return !(cout<<-1<<'\n');
    sort(o,o+n,[&](int i,int j)
        {return a[i]<a[j];});
    R(t,n){
        int i=o[t];
        if(i!=p[i]){
            ns.pb({i,q[i]});
            int tp=p[i],tq=q[i];
            p[tq]=tp,p[i]=i;
            q[tp]=tq,q[i]=i;
        }
    }
    cout<<sz(ns)<<'\n';
    for(auto u:ns) cout<<u.x+1<<' '<<u.y+1<<'\n';
    return 0;
}
/*
每个连通块，从人轻到人重挪
*/
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define int          long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define pi           pair<int,int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define FIO         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}


void solve()
{
     int n;
     cin>>n;
     int a[n];
     int sum=0,ans=0;
     rep(i,0,n){
      cin>>a[i];sum+=a[i];}
      sort(a,a+n);
      rep(i,0,n)
      {
        //cout<<a[i]*(n-i-1)<<" "<<(sum-a[i])<<endl;
             ans+=abs(a[i]*(n-1-i)-(sum-a[i]));
             sum-=a[i];
      }
      cout<<ans;

}

signed main()
{
        FIO
       
        
        int t=1;
        //cin>>t;
        while(t--)
        solve();
        cerr<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

        return 0;
}