#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    vector<ll> S(N+1);
    for (int i = 0; i < N; i++) S[i+1] = S[i] + A[i];
    ll ans = 0;
    for (int i = 1; i < N; i++) ans += A[i] * i - S[i];
    cout << ans << endl;
    return 0;
}
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

/*

*/

void run_case() {
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    int res = 0;
    for (int i = 0; i < n; i++) {
        res += a[i] * b[i];
    }

    cout << (res == 0 ? "Yes" : "No") << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    
    int T = 1;
    // cin >> T;
    for (int t = 1; t <= T; t++) {
        // cout << "Case #" << t << ": ";
        run_case();
    }
    
    return 0;
}