#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long int t,n,i,x,mx,mn,f,j,s,r,y;
    cin>>n;
    vector<long long int>v(402);
    for(i=0;i<n;i++)
    {
        cin>>x;
        v[x+200]++;
    }
    s=0;
    for(i=0;i<400;i++)
    {
        for(j=i;j<=400;j++)
        {
            if(i!=j&&v[i]>=0&&v[j]>=0)
            {
                r=(i-200)-(j-200);
                s+=(v[i]*v[j]*r*r);
            }
        }
    }
    cout<<s<<endl;
}

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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = 500 + 10;
int n, c[MAXN][MAXN];
int a[MAXN];
int b[MAXN];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            scanf("%d", &c[i][j]);
        }
    }

    a[1] = *min_element(c[1] + 1, c[1] + 1 + n);
    for (int j = 1; j <= n; ++j) {
        b[j] = c[1][j] - a[1];
    }
    for (int i = 2; i <= n; ++i) {
        a[i] = c[i][1] - b[1];
    }

    try {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                if (c[i][j] != (LL)a[i] + b[j]) {
                    throw false;
                }
            }
        }
    } catch (bool check) {
        puts("No");
        return 0;
    }

    puts("Yes");
    for (int i = 1; i <= n; ++i) {
        printf("%d ", a[i]);
    }
    puts("");
    for (int i = 1; i <= n; ++i) {
        printf("%d ", b[i]);
    }
    puts("");
    return 0;
}