#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
int main(){
    ll n; cin >> n;
    vector<vector<ll>> c(n,vector<ll>(n,0));
    ll minc = INF;
    REP(i,n)REP(j,n) {
        cin >> c[i][j];
    }
    vector<ll> b(n,0);
    vector<ll> a(n,0);
    REP(i,n) {
        if (i==0) {
            REP(j,n) b[j]=c[i][j];
        }
        else {
            a[i]=c[i][0]-b[0];
            REP(j,n) {
                if (a[i]+b[j]!=c[i][j]) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    ll amin = INF; ll bmin = INF;
    
    // cout << "test" << endl;
    // REP(i,n) cout << a[i] << " ";
    // cout << endl;
    // REP(i,n) cout << b[i] << " ";
    // cout << endl;

    REP(i,n) amin = min(amin,a[i]);
    REP(i,n) bmin = min(bmin,b[i]);
    if (amin<0 && bmin<0) {
        cout << "No" << endl;
        return 0;
    }
    if (amin<0) {
        if (bmin+amin<0) {
            cout << "No" << endl;
            return 0;
        }
        else {
            ll add = 0-amin;
            REP(i,n) {
                a[i]+=add;
                b[i]-=add;
            }
        }
    }
    if (bmin<0) {
        if (bmin+amin<0) {
            cout << "No" << endl;
            return 0;
        }
        else {
            ll add = 0-bmin;
            REP(i,n) {
                a[i]-=add;
                b[i]+=add;
            }
        }
    }
    cout << "Yes" << endl;
    REP(i,n) cout << a[i] << " ";
    cout << endl;
    REP(i,n) cout << b[i] << " ";
    cout << endl;
    return 0;
}
#include <bits/stdc++.h> 
using namespace std;
template <typename T> inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a;} 
template <typename T> inline T lcm(T a, T b) { return ((a/gcd(a,b))*b);}
#define all(x) (x).begin(),(x).end()                    
#define sort(x) sort(x.begin(),x.end())
#define maxin(x) *max_element(x.begin(),x.end())        
#define minin(x) *min_element(x.begin(),x.end())
#define lint long long int                              
#define nl '\n'
#define INF (lint)1e18
#define MOD (lint)998244353
void solve(){
       lint n;
       cin>>n;
       vector<lint> arr(n);
       for(auto &a: arr) cin>>a;
       sort(arr);
       lint ans = arr[n-1]*arr[n-1];
       lint t = arr[n-1];
       for(lint i=n-2;i>=0;i--){
           ans+=(arr[i]*arr[i])%MOD;
           ans=(ans+t*arr[i])%MOD;
           t=(2*t+arr[i])%MOD;
       }
       cout<<ans%MOD;
}
int main()
{       ios_base::sync_with_stdio(0);cin.tie(0);lint testnum=1,totalnum=1;
        //cin>>totalnum;
        for(testnum=1;testnum<=totalnum;++testnum){
                //cout<<"Case #"<<testnum<<": ";
                solve();
                cout<<nl;
        }
return 0;}

/*
        created on: 01.04.2021

*/
                      

