#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> v(n);
  for (auto &x : v) cin >> x;
  long long ans = 0;
  sort(v.begin(), v.end());
  for (long long i = 0; i < n; ++i) {
    ans += i * v[i] - (n - i - 1) * v[i];
  }
  cout << ans;
}
#include<bits/stdc++.h>
using  namespace  std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'
 #define mod 1000000007
typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    ll n;
    cin>>n;
    ll i,ar[n+2],br[n+3];
    ll sum=0;
    for(i=0;i<n;i++)cin>>ar[i];
    for(i=0;i<n;i++)
    {
        cin>>br[i];
        sum+=(ar[i]*br[i]);
    }
    if(sum==0)cout<<"Yes"<<nl;
    else cout<<"No"<<nl;
    return 0;
}
