#include <bits/stdc++.h>
#define int long long
#define elif else if
#define pb push_back

using namespace std;
vector<vector<int>> adj;

set<int> black_list;

long long bfs(int s, int en, set<int> &path){

    int n = adj.size();

    vector<bool> visited(n+1, false);
    vector<int> dist(n+1, 0);
    deque<int> q;

    visited[s] = 1;
    q.push_back(s);

    while(!q.empty()){
        int v = q.front();
        q.pop_front();
        for(auto u: adj[v]){
            if(visited[u]) continue;
            visited[u] = 1;
            dist[u] = dist[v] + 1;
            q.push_back(u);
        }
    }
    for(int x: dist) cout << x << " ";
    cout << endl;
    return dist[en];
}

void solve(){
    int n; cin >> n;
    vector<int> a(n);
    for(int &x: a) cin >> x;
    
    sort(begin(a), end(a));
    cout << a[n-1]-a[0] << endl;
    for(int x: a) cout << x << " ";
    cout << endl;
}

signed main()
{
    int t = 1; //cin >> t;
    while(t--) solve();
    return 0;
}
