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

typedef long long ll;
typedef vector <int> vi;
typedef vector < pair < int, int > > vpi;

#define pi pair< int , int >
#define pii pair< pi , int >
#define PI acos(-1)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define RE(i,a,b) for(int i=a;i<b;i++)
#define R(a) for(int i=0;i<a;i++)
#define In(a,n,val) for (int i=0;i<n;i++)a[i]=val;
#define PrtArr(a,n) for (int i=0;i<n;i++){cout << a[i] << " ";}cout << endl
#define IN(x,a,b) x >= a && x <= b
#define INO(x,a,b) x > a && x < b
#define fr first
#define sc second
#define pb push_back

#define SET(x,y)    x|=(1<<y)
#define CLEAR(x,y)  x&= ~(1<<y)
#define TOGGLE(x,y) x^=(1<<y)
#define READ(x,y)   ((bool)((ll)(x&(1<<y)) != 0))

#define sz(x) ((int)(x.size()))
#define szof(x) ((int)(sizeof(x)))
#define all(t) t.begin(),t.end()
#define frei freopen("in.in","r",stdin)
#define freo freopen("out.out","w",stdout)
#define MAX (int)1e5+100
#define OO INT_MAX
#define mod 1000000007

#define left(x) (x << 1)
#define right(x) ( ( x << 1 ) + 1)

int a[MAX];
map < int , int > mp;
int main ()
{
    int n;
    set <int> st;
    scanf("%d",&n);
    R(n)
    {
        scanf("%d",&a[i]);
        mp[a[i]]++;
        st.insert(a[i]);
    }
    if (st.size() == 1)
    {
        printf("%d\n",n);
        printf("%d",a[0]);
        RE(i,1,n)printf(" %d",a[i]);
        printf("\n");
        return 0;
    }

    set<int > ::iterator it = st.begin();
    int x1,x2,x3;
    x1 = *it;
    it++;
    x2 = *it;

    if ( st.size() == 2 && x2 - x1 == 1)
    {
        printf("%d\n",n);
        printf("%d",a[0]);
        RE(i,1,n)printf(" %d",a[i]);
        printf("\n");
        return 0;
    }
    if(st.size() == 3)
    {
        x3 = x2+1;
    }
    else
    {
        x3 = x2;
        x2--;
    }
    if (mp[x1] > mp[x3])swap(x1,x3);
    if (mp[x1]*2 >= ( ( int(mp[x2]/2) ) * 2 ))
    {
        int ans = n - mp[x1]*2;
        printf("%d\n",ans);
        mp[x3] -= mp[x1];
        mp[x2] += mp[x1]*2;
        mp[x1] = 0;
    }
    else
    {
        int ans = n - ( ( int(mp[x2]/2) ) * 2 );
        printf("%d\n",ans);
        mp[x1] += int(mp[x2]/2) ;
        mp[x3] += int(mp[x2]/2) ;
        mp[x2] = mp[x2]&1;
    }
    R(mp[x1])printf("%d ",x1);
    R(mp[x3])printf("%d ",x3);
    R(mp[x2])printf("%d ",x2);

    return 0;
}


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

typedef long long ll;
typedef vector <int> vi;
typedef vector < pair < int, int > > vpi;

#define pi pair< int , int >
#define pii pair< pi , int >
#define PI acos(-1)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define RE(i,a,b) for(int i=a;i<b;i++)
#define R(a) for(int i=0;i<a;i++)
#define In(a,n,val) for (int i=0;i<n;i++)a[i]=val;
#define PrtArr(a,n) for (int i=0;i<n;i++){cout << a[i] << " ";}cout << endl
#define IN(x,a,b) x >= a && x <= b
#define INO(x,a,b) x > a && x < b
#define fr first
#define sc second
#define pb push_back

#define SET(x,y)    x|=(1<<y)
#define CLEAR(x,y)  x&= ~(1<<y)
#define TOGGLE(x,y) x^=(1<<y)
#define READ(x,y)   ((bool)((ll)(x&(1<<y)) != 0))

#define sz(x) ((int)(x.size()))
#define szof(x) ((int)(sizeof(x)))
#define all(t) t.begin(),t.end()
#define frei freopen("in.in","r",stdin)
#define freo freopen("out.out","w",stdout)
#define MAX (int)1e5+100
#define OO INT_MAX
#define mod 1000000007

#define left(x) (x << 1)
#define right(x) ( ( x << 1 ) + 1)

int a[MAX];
map < int , int > mp;
int main ()
{
    int n;
    set <int> st;
    scanf("%d",&n);
    R(n)
    {
        scanf("%d",&a[i]);
        mp[a[i]]++;
        st.insert(a[i]);
    }
    if (st.size() < 3)
    {
        printf("%d\n",n);
        printf("%d",a[0]);
        RE(i,1,n)printf(" %d",a[i]);
        printf("\n");
        return 0;
    }
    set<int > ::iterator it = st.begin();
    int x1,x2,x3;
    x1 = *it;
    it++;
    x2 = *it;
    it++;
    x3 = *it;
    if (mp[x1] > mp[x3])swap(x1,x3);
    int ans = n - mp[x1]*2;
    printf("%d\n",ans);
    mp[x3] -= mp[x1];
    mp[x2] += mp[x1]*2;
    mp[x1] = 0;
    R(mp[x1])printf("%d ",x1);
    R(mp[x3])printf("%d ",x3);
    RE(i,1,mp[x2])printf("%d ",x2);
    printf("%d\n",x2);

    return 0;
}


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

typedef long long ll;
typedef vector <int> vi;
typedef vector < pair < int, int > > vpi;

#define pi pair< int , int >
#define pii pair< pi , int >
#define PI acos(-1)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define RE(i,a,b) for(int i=a;i<b;i++)
#define R(a) for(int i=0;i<a;i++)
#define In(a,n,val) for (int i=0;i<n;i++)a[i]=val;
#define PrtArr(a,n) for (int i=0;i<n;i++){cout << a[i] << " ";}cout << endl
#define IN(x,a,b) x >= a && x <= b
#define INO(x,a,b) x > a && x < b
#define fr first
#define sc second
#define pb push_back

#define SET(x,y)    x|=(1<<y)
#define CLEAR(x,y)  x&= ~(1<<y)
#define TOGGLE(x,y) x^=(1<<y)
#define READ(x,y)   ((bool)((ll)(x&(1<<y)) != 0))

#define sz(x) ((int)(x.size()))
#define szof(x) ((int)(sizeof(x)))
#define all(t) t.begin(),t.end()
#define frei freopen("in.in","r",stdin)
#define freo freopen("out.out","w",stdout)
#define MAX (int)1e5+100
#define OO INT_MAX
#define mod 1000000007

#define left(x) (x << 1)
#define right(x) ( ( x << 1 ) + 1)

int a[MAX];
map < int , int > mp;
int main ()
{
    int n;
    set <int> st;
    scanf("%d",&n);
    R(n)
    {
        scanf("%d",&a[i]);
        mp[a[i]]++;
        st.insert(a[i]);
    }
    if (st.size() == 1)
    {
        printf("%d\n",n);
        printf("%d",a[0]);
        RE(i,1,n)printf(" %d",a[i]);
        printf("\n");
        return 0;
    }

    set<int > ::iterator it = st.begin();
    int x1,x2,x3;
    x1 = *it;
    it++;
    x2 = *it;

    if ( st.size() == 2 && x2 - x1 == 1)
    {
        printf("%d\n",n);
        printf("%d",a[0]);
        RE(i,1,n)printf(" %d",a[i]);
        printf("\n");
        return 0;
    }
    if(st.size() == 3)
    {
        x3 = x2+1;
    }
    else
    {
        x3 = x2;
        x2--;
    }
    if (mp[x1] > mp[x3])swap(x1,x3);
    int ans = n - mp[x1]*2;
    printf("%d\n",ans);
    mp[x3] -= mp[x1];
    mp[x2] += mp[x1]*2;
    mp[x1] = 0;
    R(mp[x1])printf("%d ",x1);
    R(mp[x3])printf("%d ",x3);
    RE(i,1,mp[x2])printf("%d ",x2);
    printf("%d\n",x2);

    return 0;
}


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

typedef long long ll;
typedef vector <int> vi;
typedef vector < pair < int, int > > vpi;

#define pi pair< int , int >
#define pii pair< pi , int >
#define PI acos(-1)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define RE(i,a,b) for(int i=a;i<b;i++)
#define R(a) for(int i=0;i<a;i++)
#define In(a,n,val) for (int i=0;i<n;i++)a[i]=val;
#define PrtArr(a,n) for (int i=0;i<n;i++){cout << a[i] << " ";}cout << endl
#define IN(x,a,b) x >= a && x <= b
#define INO(x,a,b) x > a && x < b
#define fr first
#define sc second
#define pb push_back

#define SET(x,y)    x|=(1<<y)
#define CLEAR(x,y)  x&= ~(1<<y)
#define TOGGLE(x,y) x^=(1<<y)
#define READ(x,y)   ((bool)((ll)(x&(1<<y)) != 0))

#define sz(x) ((int)(x.size()))
#define szof(x) ((int)(sizeof(x)))
#define all(t) t.begin(),t.end()
#define frei freopen("in.in","r",stdin)
#define freo freopen("out.out","w",stdout)
#define MAX (int)1e5+100
#define OO INT_MAX
#define mod 1000000007

#define left(x) (x << 1)
#define right(x) ( ( x << 1 ) + 1)

int a[MAX];
map < int , int > mp;
int main ()
{
    int qqq=1;
    int n;
    set <int> st;
    scanf("%d",&n);
    R(n)
    {
        scanf("%d",&a[i]);
        mp[a[i]]++;
        st.insert(a[i]);
    }
    if (st.size() == 1)
    {
        printf("%d\n",n);
        printf("%d",a[0]);
        RE(i,1,n)printf(" %d",a[i]);
        printf("\n");
        return 0;
    }

    set<int > ::iterator it = st.begin();
    int x1,x2,x3;
    x1 = *it;
    it++;
    x2 = *it;

    if ( st.size() == 2 && x2 - x1 == 1)
    {
        printf("%d\n",n);
        printf("%d",a[0]);
        RE(i,1,n)printf(" %d",a[i]);
        printf("\n");
        return 0;
    }
    if(st.size() == 3)
    {
        x3 = x2+1;
    }
    else
    {
        x3 = x2;
        x2--;
    }
    if (mp[x1] > mp[x3])swap(x1,x3);
    int ans = n - mp[x1]*2;
    printf("%d\n",ans);
    mp[x3] -= mp[x1];
    mp[x2] += mp[x1]*2;
    mp[x1] = 0;
    R(mp[x1])printf("%d ",x1);
    R(mp[x2])printf("%d ",x2);
    R(mp[x3])printf("%d ",x3);

    return 0;
}


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

typedef long long ll;
typedef vector <int> vi;
typedef vector < pair < int, int > > vpi;

#define pi pair< int , int >
#define pii pair< pi , int >
#define PI acos(-1)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define RE(i,a,b) for(int i=a;i<b;i++)
#define R(a) for(int i=0;i<a;i++)
#define In(a,n,val) for (int i=0;i<n;i++)a[i]=val;
#define PrtArr(a,n) for (int i=0;i<n;i++){cout << a[i] << " ";}cout << endl
#define IN(x,a,b) x >= a && x <= b
#define INO(x,a,b) x > a && x < b
#define fr first
#define sc second
#define pb push_back

#define SET(x,y)    x|=(1<<y)
#define CLEAR(x,y)  x&= ~(1<<y)
#define TOGGLE(x,y) x^=(1<<y)
#define READ(x,y)   ((bool)((ll)(x&(1<<y)) != 0))

#define sz(x) ((int)(x.size()))
#define szof(x) ((int)(sizeof(x)))
#define all(t) t.begin(),t.end()
#define frei freopen("in.in","r",stdin)
#define freo freopen("out.out","w",stdout)
#define MAX (int)1e5+100
#define OO INT_MAX
#define mod 1000000007

#define left(x) (x << 1)
#define right(x) ( ( x << 1 ) + 1)

int a[MAX];
map < int , int > mp;
int main ()
{
    int n;
    set <int> st;
    scanf("%d",&n);
    R(n)
    {
        scanf("%d",&a[i]);
        mp[a[i]]++;
        st.insert(a[i]);
    }
    if (st.size() == 1)
    {
        printf("%d\n",n);
        printf("%d",a[0]);
        RE(i,1,n)printf(" %d",a[i]);
        printf("\n");
        return 0;
    }

    set<int > ::iterator it = st.begin();
    int x1,x2,x3;
    x1 = *it;
    it++;
    x2 = *it;

    if ( st.size() == 2 && x2 - x1 == 1)
    {
        printf("%d\n",n);
        printf("%d",a[0]);
        RE(i,1,n)printf(" %d",a[i]);
        printf("\n");
        return 0;
    }
    if(st.size() == 3)
    {
        x3 = x2+1;
    }
    else
    {
        x3 = x2;
        x2--;
    }
    if (mp[x1] > mp[x3])swap(x1,x3);
    int ans = n - mp[x1]*2;
    printf("%d\n",ans);
    mp[x3] -= mp[x1];
    mp[x2] += mp[x1]*2;
    mp[x1] = 0;
    R(mp[x1])printf("%d ",x1);
    R(mp[x2])printf("%d ",x2);
    R(mp[x3])printf("%d ",x3);

    return 0;
}


#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define P acos(-1)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define bits(x) __builtin_popcount(x)

#define LAST_OUT(S) {cout << S << endl; exit(0);}

using namespace std;

const int M = 100500;
vector <int> a, b, diff;
int cnt[220000];
int cntt[220000];
int cnt2[220000];
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //cout << fixed << setprecision(10);
    //freopen("stars.in", "r", stdin);
    //freopen("stars.out", "w", stdout);

    int n;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        cnt[x + M]++;
        cntt[x + M]++;
        a.push_back(x);
        diff.push_back(x + M);
    }

    sort(all(a));
    sort(all(diff));
    diff.resize(unique(all(diff)) - diff.begin());

    if (diff.size() == 1 || (diff.size() == 2 && abs(diff[0] - diff[1]) == 1))
    {
        cout << n << endl;
        for (int i = 0; i < a.size(); i++)
            cout << a[i] << " ";
        return 0;
    }

    else if (diff.size() == 2 && abs(diff[0] - diff[1]) == 2)
    {
        diff.push_back(a[0] + 1 + M);
        sort(all(diff));
    }

    while (cnt[diff[0]] > 0 && cnt[diff[2]] > 0)
    {
        cnt[diff[0]]--;
        cnt[diff[2]]--;
        cnt2[diff[1]]+=2;
    }

    cnt2[diff[1]] += cntt[diff[1]];

    for (int i = 0; i < cnt2[diff[1]]; i++)
        b.push_back(diff[1] - M);
    for (int i = 0; i < cnt[diff[2]]; i++)
        b.push_back(diff[2] - M);
    for (int i = 0; i < cnt[diff[0]]; i++)
        b.push_back(diff[0] - M);

    int ans = min(cntt[diff[0]],cnt[diff[0]]);
    ans +=    min(cntt[diff[1]],cnt2[diff[1]]);
    ans +=    min(cntt[diff[2]],cnt[diff[2]]);

    cout << ans << endl;

    for (int i = 0; i < b.size(); i++)
        cout << b[i] << " ";
    return 0;
}
/*
2 1000000000

4 234234
*/


#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define P acos(-1)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define bits(x) __builtin_popcount(x)

#define LAST_OUT(S) {cout << S << endl; exit(0);}

using namespace std;

const int M = 100500;
vector <int> a, b, diff;
int cnt[220000];
int cntt[220000];
int cnt2[220000];
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //cout << fixed << setprecision(10);
    //freopen("stars.in", "r", stdin);
    //freopen("stars.out", "w", stdout);

    int n;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        cnt[x + M]++;
        cntt[x + M]++;
        a.push_back(x);
        diff.push_back(x + M);
    }

    sort(all(a));
    sort(all(diff));
    diff.resize(unique(all(diff)) - diff.begin());

    if (diff.size() == 2 && abs(diff[0] - diff[1]) == 1)
    {
        cout << n << endl;
        for (int i = 0; i < a.size(); i++)
            cout << a[i] << " ";
        return 0;
    }

    else if (diff.size() == 2 && abs(diff[0] - diff[1]) == 2)
    {
        diff.push_back(a[0] + 1 + M);
        sort(all(diff));
    }

    while (cnt[diff[0]] > 0 && cnt[diff[2]] > 0)
    {
        cnt[diff[0]]--;
        cnt[diff[2]]--;
        cnt2[diff[1]]+=2;
    }

    cnt2[diff[1]] += cntt[diff[1]];

    for (int i = 0; i < cnt2[diff[1]]; i++)
        b.push_back(diff[1] - M);
    for (int i = 0; i < cnt[diff[2]]; i++)
        b.push_back(diff[2] - M);
    for (int i = 0; i < cnt[diff[0]]; i++)
        b.push_back(diff[0] - M);

    int ans = min(cntt[diff[0]],cnt[diff[0]]);
    ans +=    min(cntt[diff[1]],cnt2[diff[1]]);
    ans +=    min(cntt[diff[2]],cnt[diff[2]]);

    cout << ans << endl;

    for (int i = 0; i < b.size(); i++)
        cout << b[i] << " ";
    return 0;
}
/*
2 1000000000

4 234234
*/


#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define P acos(-1)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define bits(x) __builtin_popcount(x)

#define LAST_OUT(S) {cout << S << endl; exit(0);}

using namespace std;

const int M = 100500;
vector <int> a, b, diff;
int cnt[220000];
int cntt[220000];
int cntt2[220000];
int cnt2[220000];
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //cout << fixed << setprecision(10);
    //freopen("stars.in", "r", stdin);
    //freopen("stars.out", "w", stdout);

    int n;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        cnt[x + M]++;
        cntt[x + M]++;
        a.push_back(x);
        diff.push_back(x + M);
    }

    sort(all(a));
    sort(all(diff));
    diff.resize(unique(all(diff)) - diff.begin());

    if (diff.size() == 1 || (diff.size() == 2 && abs(diff[0] - diff[1]) == 1))
    {
        cout << n << endl;
        for (int i = 0; i < a.size(); i++)
            cout << a[i] << " ";
        return 0;
    }

    else if (diff.size() == 2 && abs(diff[0] - diff[1]) == 2)
    {
        diff.push_back(a[0] + 1 + M);
        sort(all(diff));
    }

    while (cnt[diff[0]] > 0 && cnt[diff[2]] > 0)
    {
        cnt[diff[0]]--;
        cnt[diff[2]]--;
        cnt2[diff[1]]+=2;
    }

    cnt2[diff[1]] += cntt[diff[1]];

    for (int i = 0; i < cnt2[diff[1]]; i++)
        b.push_back(diff[1] - M);
    for (int i = 0; i < cnt[diff[2]]; i++)
        b.push_back(diff[2] - M);
    for (int i = 0; i < cnt[diff[0]]; i++)
        b.push_back(diff[0] - M);

    for (int i = 0; i < b.size(); i++)
        cntt2[b[i] + M]++;

    int ans = 0;
    for (int i = 0; i < diff.size(); i++)
        ans += min(cntt2[diff[i]], cntt[diff[i]]);

    cout << ans << endl;

    for (int i = 0; i < b.size(); i++)
        cout << b[i] << " ";
    return 0;
}
/*
2 1000000000

4 234234
*/


#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define P acos(-1)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define bits(x) __builtin_popcount(x)

#define LAST_OUT(S) {cout << S << endl; exit(0);}

using namespace std;

const int M = 100500;
vector <int> a, b, diff, c;
int cnt[220000];
int cnt1[220000];
int cnt3[220000];
int cntt[220000];
int cntt2[220000];
int cntt3[220000];
int cnt2[220000];
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //cout << fixed << setprecision(10);
    //freopen("stars.in", "r", stdin);
    //freopen("stars.out", "w", stdout);

    int n;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        cnt[x + M]++;
        cntt[x + M]++;
        a.push_back(x);
        diff.push_back(x + M);
    }

    sort(all(a));
    sort(all(diff));
    diff.resize(unique(all(diff)) - diff.begin());

    if (diff.size() == 1 || (diff.size() == 2 && abs(diff[0] - diff[1]) == 1))
    {
        cout << n << endl;
        for (int i = 0; i < a.size(); i++)
            cout << a[i] << " ";
        return 0;
    }

    else if (diff.size() == 2 && abs(diff[0] - diff[1]) == 2)
    {
        diff.push_back(a[0] + 1 + M);
        sort(all(diff));
    }

    while (cnt[diff[0]] > 0 && cnt[diff[2]] > 0)
    {
        cnt[diff[0]]--;
        cnt[diff[2]]--;
        cnt2[diff[1]]+=2;
    }

    cnt2[diff[1]] += cntt[diff[1]];

    for (int i = 0; i < cnt2[diff[1]]; i++)
        b.push_back(diff[1] - M);
    for (int i = 0; i < cnt[diff[2]]; i++)
        b.push_back(diff[2] - M);
    for (int i = 0; i < cnt[diff[0]]; i++)
        b.push_back(diff[0] - M);

    for (int i = 0; i < b.size(); i++)
        cntt2[b[i] + M]++;

    int ans1 = 0;
    for (int i = 0; i < diff.size(); i++)
        ans1 += min(cntt2[diff[i]], cntt[diff[i]]);

    while (cnt[diff[1]] >= 2)
    {
        //cout << "FUCK" << endl;
        cnt1[diff[0]]++;
        cnt3[diff[2]]++;
        cnt[diff[1]]-=2;
    }

    cnt1[diff[0]] += cntt[diff[0]];
    cnt3[diff[2]] += cntt[diff[2]];

    for (int i = 0; i < cnt1[diff[0]]; i++)
        c.push_back(diff[0] - M);
    for (int i = 0; i< cnt[diff[1]]; i++)
        c.push_back(diff[1] - M);
    for (int i = 0; i < cnt3[diff[2]]; i++)
        c.push_back(diff[2] - M);

    for (int i = 0; i < c.size(); i++)
        cntt3[c[i] + M]++;

    int ans2 = 0;
    for (int i = 0; i < diff.size(); i++)
        ans2 += min(cntt3[diff[i]], cntt[diff[i]]);

    if (ans1 < ans2)
    {
        cout << ans1 << endl;
        for (int i = 0; i < b.size(); i++)
            cout << b[i] << " ";
    }
    else
    {
        cout << ans2 << endl;
        for (int i = 0; i < c.size(); i++)
            cout << c[i] << " ";
    }

    return 0;
}
/*
2 1000000000

4 234234
*/


#include <bits/stdc++.h>
using namespace std;
#define _____ ios::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef pair<int,int> pii;
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
const int maxn = 1e5 + 5;
int a[maxn];
int n;
int main(){
    _____
    #ifdef FWL
    freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    #endif // FWL
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int r = *max_element(a+1,a+1+n),l = *min_element(a+1,a+1+n);
    int t = r-l;
    if(t < 2){
        cout << 0 << '\n';
        for(int i = 1; i <= n; i++){
            cout << a[i] << ' ';
        }
        cout << '\n';
    }
    else{
        int x = 0, y = 0, z = 0;
        for(int i = 1; i <= n; i++){
            if(a[i] == l)x++;
            else if(a[i] == r)y++;
            else z++;
        }
        x = min(x,y);
        y = x;
        if(x*2 >= (z>>1)*2){
            cout << n-x*2 << '\n';
            for(int i = 1; i <= n; i++){
                if(a[i] == l && x){
                    x--;cout << l+1 << ' ';
                }
                else if(a[i] == r && y){
                    y--;cout << l+1 << ' ';
                }
                else{
                    cout << a[i] << ' ';
                }
            }
            cout << '\n';
        }
        else{
            cout << n-(z>>1)*2 << '\n';
            x = y = z>>1;
            for(int i = 1; i <= n; i++){
                if(a[i] == l+1){
                    if(x){
                        x--;cout<< l << ' ';
                    }
                    else if(y){
                        y--;cout<< r << ' ';
                    }
                    else cout << l+1 << ' ';
                }
            }
            cout << '\n';
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define _____ ios::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
#define int long long
typedef pair<int,int> pii;
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
const int maxn = 1e5 + 10;
int a[maxn];
int n;
signed main(){
    _____
    #ifdef FWL
    freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    #endif // FWL
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int r = *max_element(a+1,a+1+n),l = *min_element(a+1,a+1+n);
    int t = r-l;
    if(t < 2){
        cout << n << '\n';
        for(int i = 1; i <= n; i++){
            cout << a[i] << ' ';
        }
        cout << '\n';
    }
    else{
        int x = 0, y = 0, z = 0;
        for(int i = 1; i <= n; i++){
            if(a[i] == l)x++;
            else if(a[i] == r)y++;
            else z++;
        }
        x = min(x,y);
        y = x;
        if(x >= (z/2)){
            cout << n-x*2 << '\n';
            for(int i = 1; i <= n; i++){
                if(a[i] == l && x){
                    x--;cout << l+1 << ' ';
                }
                else if(a[i] == r && y){
                    y--;cout << l+1 << ' ';
                }
                else{
                    cout << a[i] << ' ';
                }
            }
            cout << '\n';
        }
        else{
            cout << n-(z>>1)*2 << '\n';
            x = z>>1;
            x *= 2;
            for(int i = 1; i <= n; i++){
                if(a[i] == l+1){
                    if(x){cout << ((x&1)?l:r); x--;}
                    else cout << l+1;
                }
                if(i != n)cout << ' ';
            }
            cout << '\n';
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define _____ ios::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef pair<int,int> pii;
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
const int maxn = 1e5 + 5;
int a[maxn];
int n;
int main(){
    _____
    #ifdef FWL
    freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    #endif // FWL
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int r = *max_element(a+1,a+1+n),l = *min_element(a+1,a+1+n);
    int t = r-l;
    if(t < 2){
        cout << n << '\n';
        for(int i = 1; i <= n; i++){
            cout << a[i] << ' ';
        }
        cout << '\n';
    }
    else{
        int x = 0, y = 0, z = 0;
        for(int i = 1; i <= n; i++){
            if(a[i] == l)x++;
            else if(a[i] == r)y++;
            else z++;
        }
        x = min(x,y);
        y = x;
        if(x*2 >= (z>>1)*2){
            cout << n-x*2 << '\n';
            for(int i = 1; i <= n; i++){
                if(a[i] == l && x){
                    x--;cout << l+1 << ' ';
                }
                else if(a[i] == r && y){
                    y--;cout << l+1 << ' ';
                }
                else{
                    cout << a[i] << ' ';
                }
            }
            cout << '\n';
        }
        else{
            cout << n-(z>>1)*2 << '\n';
            x = y = z>>1;
            for(int i = 1; i <= n; i++){
                if(a[i] == l+1){
                    if(x){
                        x--;cout<< l << ' ';
                    }
                    else if(y){
                        y--;cout<< r << ' ';
                    }
                    else cout << l+1 << ' ';
                }
            }
            cout << '\n';
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define _____ ios::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
#define int long long
typedef pair<int,int> pii;
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
const int maxn = 1e5 + 10;
int a[maxn];
int n;
signed main(){
    _____
    #ifdef FWL
    freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    #endif // FWL
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int r = *max_element(a+1,a+1+n),l = *min_element(a+1,a+1+n);
    int t = r-l;
    if(t < 2){
        cout << n << '\n';
        for(int i = 1; i <= n; i++){
            cout << a[i];
            if(i!=n)cout << ' ';
        }
        cout << '\n';
    }
    else{
        int x = 0, y = 0, z = 0;
        for(int i = 1; i <= n; i++){
            if(a[i] == l)x++;
            else if(a[i] == r)y++;
            else z++;
        }
        x = min(x,y);
        y = x;
        if(x >= (z/2)){
            cout << n-x*2 << '\n';
            for(int i = 1; i <= n; i++){
                if(a[i] == l && x){
                    x--;cout << l+1;
                }
                else if(a[i] == r && y){
                    y--;cout << l+1;
                }
                else{
                    cout << a[i];
                }
                if(i != n)cout << ' ';
            }
            cout << '\n';
        }
        else{
            cout << n-(z>>1)*2 << '\n';
            x = z>>1;
            x *= 2;
            for(int i = 1; i <= n; i++){
                if(a[i] == l+1){
                    if(x){cout << ((x&1)?l:r); x--;}
                    else cout << l+1;
                }
                else cout << a[i];
                if(i != n)cout << ' ';
            }
            cout << '\n';
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define _____ ios::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
#define int long long
typedef pair<int,int> pii;
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
const int maxn = 1e5 + 5;
int a[maxn];
int n;
signed main(){
    _____
    #ifdef FWL
    freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    #endif // FWL
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int r = *max_element(a+1,a+1+n),l = *min_element(a+1,a+1+n);
    int t = r-l;
    if(t < 2){
        cout << n << '\n';
        for(int i = 1; i <= n; i++){
            cout << a[i] << ' ';
        }
        cout << '\n';
    }
    else{
        int x = 0, y = 0, z = 0;
        for(int i = 1; i <= n; i++){
            if(a[i] == l)x++;
            else if(a[i] == r)y++;
            else z++;
        }
        x = min(x,y);
        y = x;
        if(x >= (z/2)){
            cout << n-x*2 << '\n';
            for(int i = 1; i <= n; i++){
                if(a[i] == l && x){
                    x--;cout << l+1 << ' ';
                }
                else if(a[i] == r && y){
                    y--;cout << l+1 << ' ';
                }
                else{
                    cout << a[i] << ' ';
                }
            }
            cout << '\n';
        }
        else{
            cout << n-(z>>1)*2 << '\n';
            x = y = z>>1;
            for(int i = 1; i <= n; i++){
                if(a[i] == l+1){
                    if(x){
                        x--;cout<< l << ' ';
                    }
                    else if(y){
                        y--;cout<< r << ' ';
                    }
                    else cout << l+1 << ' ';
                }
            }
            cout << '\n';
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define _____ ios::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
#define int long long
typedef pair<int,int> pii;
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
const int maxn = 1e5 + 10;
int a[maxn];
int n;
signed main(){
    _____
    #ifdef FWL
    freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    #endif // FWL
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int r = *max_element(a+1,a+1+n),l = *min_element(a+1,a+1+n);
    int t = r-l;
    if(t < 2){
        cout << n << '\n';
        for(int i = 1; i <= n; i++){
            cout << a[i] << ' ';
        }
        cout << '\n';
    }
    else{
        int x = 0, y = 0, z = 0;
        for(int i = 1; i <= n; i++){
            if(a[i] == l)x++;
            else if(a[i] == r)y++;
            else z++;
        }
        x = min(x,y);
        y = x;
        if(x >= (z/2)){
            cout << n-x*2 << '\n';
            for(int i = 1; i <= n; i++){
                if(a[i] == l && x){
                    x--;cout << l+1 << ' ';
                }
                else if(a[i] == r && y){
                    y--;cout << l+1 << ' ';
                }
                else{
                    cout << a[i] << ' ';
                }
            }
            cout << '\n';
        }
        else{
            cout << n-(z>>1)*2 << '\n';
            x = y = z>>1;
            for(int i = 1; i <= n; i++){
                if(a[i] == l+1){
                    if(y){
                        y--;cout<< r << ' ';
                    }
                    else if(x){
                        x--;cout<< l << ' ';
                    }
                    else cout << l+1 << ' ';
                }
            }
            cout << '\n';
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define _____ ios::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
#define int long long
typedef pair<int,int> pii;
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
const int maxn = 1e5 + 10;
int a[maxn];
int n;
signed main(){
    _____
    #ifdef FWL
    freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    #endif // FWL
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int r = *max_element(a+1,a+1+n),l = *min_element(a+1,a+1+n);
    int t = r-l;
    if(t < 2){
        cout << n << '\n';
        for(int i = 1; i <= n; i++){
            cout << a[i] << ' ';
        }
        cout << '\n';
    }
    else{
        int x = 0, y = 0, z = 0;
        for(int i = 1; i <= n; i++){
            if(a[i] == l)x++;
            else if(a[i] == r)y++;
            else z++;
        }
        x = min(x,y);
        y = x;
        if(x >= (z/2)){
            cout << n-x*2 << '\n';
            for(int i = 1; i <= n; i++){
                if(a[i] == l && x){
                    x--;cout << l+1 << ' ';
                }
                else if(a[i] == r && y){
                    y--;cout << l+1 << ' ';
                }
                else{
                    cout << a[i] << ' ';
                }
            }
            cout << '\n';
        }
        else{
            cout << n-(z>>1)*2 << '\n';
            x = z>>1;
            x *= 2;
            for(int i = 1; i <= n; i++){
                if(a[i] == l+1){
                    if(x){cout << (x&1)?l:r << ' ';x--;}
                    else cout << l+1 << ' ';
                }
            }
            cout << '\n';
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define _____ ios::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
#define int long long
typedef pair<int,int> pii;
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
const int maxn = 1e5 + 10;
int a[maxn];
int n;
signed main(){
    _____
    #ifdef FWL
    freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    #endif // FWL
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int r = *max_element(a+1,a+1+n),l = *min_element(a+1,a+1+n);
    int t = r-l;
    if(t < 2){
        cout << n << '\n';
        for(int i = 1; i <= n; i++){
            cout << a[i];
            if(i!=n)cout << ' ';
        }
        cout << '\n';
    }
    else{
        int x = 0, y = 0, z = 0;
        for(int i = 1; i <= n; i++){
            if(a[i] == l)x++;
            else if(a[i] == r)y++;
            else z++;
        }
        x = min(x,y);
        y = x;
        if(x >= (z/2)){
            cout << n-x*2 << '\n';
            for(int i = 1; i <= n; i++){
                if(a[i] == l && x){
                    x--;cout << l+1;
                }
                else if(a[i] == r && y){
                    y--;cout << l+1;
                }
                else{
                    cout << a[i];
                }
                if(i != n)cout << ' ';
            }
            cout << '\n';
        }
        else{
            cout << n-(z>>1)*2 << '\n';
            x = z>>1;
            x *= 2;
            for(int i = 1; i <= n; i++){
                if(a[i] == l+1){
                    if(x){cout << ((x&1)?l:r); x--;}
                    else cout << l+1;
                }
                if(i != n)cout << ' ';
            }
            cout << '\n';
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+5;
int a[N];
int main(){
    int n,ans=0;
    scanf("%d",&n);
    int maxn=-N,minn=N,mid=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        maxn=max(maxn,a[i]);
        minn=min(minn,a[i]);
    }
    if(maxn-minn!=2){
        printf("%d\n",n);
        for(int i=0;i<n;i++)
            printf("%d%c",a[i],(i!=n-1?' ':'\n'));
        return 0;
    }
    mid=(maxn+minn)/2;
    int cmax=0,cmin=0,cmid=0;
    for(int i=0;i<n;i++){
        cmax+=(a[i]==maxn);
        cmin+=(a[i]==minn);
        cmid+=(a[i]==mid);
    }
    sort(a,a+n);
    if(cmid/2>min(cmax,cmin)){
        ans=n-cmid/2*2;
        for(int i=0;i<n/2;i++){
            if(a[i]==mid&&cmid>1){
                a[i]+=(cmid&1)*2-1;
            }
        }
    }
    else{
        ans=n-2*min(cmax,cmin);
        for(int i=0;i<n/2;i++){
            if(a[n-1-i]-a[i]==2){
                a[n-1-i]--;
                a[i]++;
            }
        }
    }
    printf("%d\n",ans);
    for(int i=0;i<n;i++)
        printf("%d%c",a[i],(i!=n-1?' ':'\n'));
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+5;
int a[N];
int main(){
    int n,ans=0;
    scanf("%d",&n);
    int maxn=-N,minn=N,mid=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        maxn=max(maxn,a[i]);
        minn=min(minn,a[i]);
    }
    if(maxn-minn!=2){
        printf("%d\n",n);
        for(int i=0;i<n;i++)
            printf("%d%c",a[i],(i!=n-1?' ':'\n'));
        return 0;
    }
    mid=(maxn+minn)/2;
    int cmax=0,cmin=0,cmid=0;
    for(int i=0;i<n;i++){
        cmax+=(a[i]==maxn);
        cmin+=(a[i]==minn);
        cmid+=(a[i]==mid);
    }
    sort(a,a+n);
    if(cmid/2>min(cmax,cmin)){
        ans=n-cmid/2*2;
        for(int i=0;i<n/2;i++){
            if(a[i]==mid&&cmid>1){
                a[i]+=(cmid&1)*2-1;
                cmid--;
            }
        }
    }
    else{
        ans=n-2*min(cmax,cmin);
        for(int i=0;i<n/2;i++){
            if(a[n-1-i]-a[i]==2){
                a[n-1-i]--;
                a[i]++;
            }
        }
    }
    printf("%d\n",ans);
    for(int i=0;i<n;i++)
        printf("%d%c",a[i],(i!=n-1?' ':'\n'));
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+5;
int a[N];
int main(){
    int n,ans=0;
    scanf("%d",&n);
    int maxn=-N,minn=N,mid=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        maxn=max(maxn,a[i]);
        minn=min(minn,a[i]);
    }
    if(maxn-minn!=2){
        printf("%d\n",n);
        for(int i=0;i<n;i++)
            printf("%d%c",a[i],(i!=n-1?' ':'\n'));
        return 0;
    }
    mid=(maxn+minn)/2;
    int cmax=0,cmin=0,cmid=0;
    for(int i=0;i<n;i++){
        cmax+=(a[i]==maxn);
        cmin+=(a[i]==minn);
        cmid+=(a[i]==mid);
    }
    sort(a,a+n);
    if(cmid/2>min(cmax,cmin)){
        ans=n-cmid/2*2;
        cmid-=(cmid&1);
        for(int i=0;i<n;i++){
            if(a[i]==mid){
                a[i]+=(cmid&1)*2-1;
                cmid--;
            }
        }
    }
    else{
        ans=n-2*min(cmax,cmin);
        for(int i=0;i<n/2;i++){
            if(a[n-1-i]-a[i]==2){
                a[n-1-i]--;
                a[i]++;
            }
        }
    }
    printf("%d\n",ans);
    for(int i=0;i<n;i++)
        printf("%d%c",a[i],(i!=n-1?' ':'\n'));
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+5;
int a[N];
int main(){
    int n,ans=0;
    scanf("%d",&n);
    int maxn=-N,minn=N,mid=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        maxn=max(maxn,a[i]);
        minn=min(minn,a[i]);
    }
    if(maxn-minn!=2){
        printf("%d\n",n);
        for(int i=0;i<n;i++)
            printf("%d%c",a[i],(i!=n-1?' ':'\n'));
        return 0;
    }
    mid=(maxn+minn)/2;
    int cmax=0,cmin=0,cmid=0;
    for(int i=0;i<n;i++){
        cmax+=(a[i]==maxn);
        cmin+=(a[i]==minn);
        cmid+=(a[i]==mid);
    }
    sort(a,a+n);
    if(cmid/2>min(cmax,cmin)){
        cmid=cmid/2*2;
        ans=n-cmid;
        for(int i=0;i<n;i++){
            if(a[i]==mid&&cmid){
                a[i]+=(cmid&1)*2-1;
                cmid--;
            }
        }
    }
    else{
        ans=n-2*min(cmax,cmin);
        for(int i=0;i<n/2;i++){
            if(a[n-1-i]-a[i]==2){
                a[n-1-i]--;
                a[i]++;
            }
        }
    }
    printf("%d\n",ans);
    for(int i=0;i<n;i++)
        printf("%d%c",a[i],(i!=n-1?' ':'\n'));
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+5;
int a[N];
int main(){
    int n,ans=0;
    scanf("%d",&n);
    int maxn=-N,minn=N,mid=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        maxn=max(maxn,a[i]);
        minn=min(minn,a[i]);
    }
    if(maxn-minn!=2){
        printf("%d\n",n);
        for(int i=0;i<n;i++)
            printf("%d%c",a[i],(i!=n-1?' ':'\n'));
        return 0;
    }
    mid=(maxn+minn)/2;
    int cmax=0,cmin=0,cmid=0;
    for(int i=0;i<n;i++){
        cmax+=(a[i]==maxn);
        cmin+=(a[i]==minn);
        cmid+=(a[i]==mid);
    }
    sort(a,a+n);
    if(cmid/2>min(cmax,cmin)){
        ans=n-cmid/2*2;
        for(int i=0;i<n;i++){
            if(a[i]==mid&&cmid>1){
                a[i]+=(cmid&1)*2-1;
                cmid--;
            }
        }
    }
    else{
        ans=n-2*min(cmax,cmin);
        for(int i=0;i<n/2;i++){
            if(a[n-1-i]-a[i]==2){
                a[n-1-i]--;
                a[i]++;
            }
        }
    }
    printf("%d\n",ans);
    for(int i=0;i<n;i++)
        printf("%d%c",a[i],(i!=n-1?' ':'\n'));
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+5;
int a[N];
int main(){
    int n,ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    for(int i=0;i<n/2;i++){
        if(a[n-1-i]-a[i]==2){
            a[n-1-i]--;
            a[i]++;
        }
        else
            ans+=2;
    }
    ans+=(n&1);
    printf("%d\n",ans);
    for(int i=0;i<n;i++)
        printf("%d%c",a[i],(i!=n-1?' ':'\n'));
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <fstream>
#include <memory>
#include <map>
#include <math.h>
#include <cmath>
#include <set>
#include <iomanip>

#define x1 qwe
#define x2 mem
#define y2 kek
#define y1 cheburek

#define sqr(a) a * a

const int N = 200005;
const int MAX_NUM = 100001;
#define pi 3.14159265359

using namespace std;

int a[N], n, r;

bool used[N];
int changed[N];
int cnt[N];

vector<pair<int,int>> odd;
vector<pair<int,int>> even;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);

    cin >> n;

    int l = 1e9;

    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] += 100000;
        if (a[i] % 2 == 0) odd.push_back({a[i], i});
        else even.push_back({a[i], i});
    }

    sort(even.begin(), even.end());
    sort(odd.begin(), odd.end());

    int i = 0, j = odd.size() - 1;

    int ans = n;

    while(i < j) {

        if (odd[i].first == odd[j].first) break;

        a[odd[i].second] = a[odd[j].second] = (odd[i].first + odd[j].first) / 2;
        ans -= 2;
        i++;
        j--;
    }

    i = 0, j = even.size() - 1;

    while(i < j) {

        if (even[i].first == even[j].first) break;

        a[even[i].second] = a[even[j].second] = (even[i].first + even[j].first) / 2;
        ans -= 2;
        i++;
        j--;
    }

    cout << ans << "\n";

    for(int i = 0; i < n; ++i) {
        cout << a[i] - 100000 << ' ';
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <fstream>
#include <memory>
#include <map>
#include <math.h>
#include <cmath>
#include <set>
#include <iomanip>

#define x1 qwe
#define x2 mem
#define y2 kek
#define y1 cheburek

#define sqr(a) a * a

const int N = 200005;
const int MAX_NUM = 100001;
#define pi 3.14159265359

using namespace std;

int a[N], n, r;

bool used[N];
int changed[N];
int cnt[N];

vector<pair<int,int>> odd;
vector<pair<int,int>> even;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);

    cin >> n;

    int l = 1e9, r = -1;

    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] += 100000;
        l = min(l, a[i]);
        r = max(r, a[i]);
    }

    if (r - l <= 1) {
        cout << n << "\n";
        for(int i = 0; i < n; ++i) {
            cout << a[i] - 100000 << " ";
        }
        return 0;
    }

    int cnt_l = 0, cnt_mid = 0, cnt_r = 0;

    for(int i = 0; i < n; ++i) {
        if (a[i] == l){
            cnt_l++;
        } else if (a[i] == r) {
            cnt_r++;
        } else {
            cnt_mid++;
        }
    }

    int mid = (l + r) >> 1;

    cnt_l = cnt_r = min(cnt_l, cnt_r);

    if (cnt_mid % 2 == 1) cnt_mid--;

    bool ok = (cnt_l * 2 >= cnt_mid);

    cout << n - max(cnt_l * 2, cnt_mid) << "\n";

    for(int i = 0; i < n; ++i) {
        if (ok) {
            if (a[i] == l && cnt_l) {
                cnt_l--;
                a[i] = mid;
            }
            else if (a[i] == r && cnt_r) {
                cnt_r--;
                a[i] = mid;
            }
        } else if (a[i] == mid){
            if (!cnt_mid) continue;
            if (cnt_mid % 2 == 1) {
                a[i] = l;
            } else {
                a[i] = r;
            }
            cnt_mid--;
        }
    }

    for(int i = 0; i < n; ++i) {
        cout << a[i] - 100000 << ' ';
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <fstream>
#include <memory>
#include <map>
#include <math.h>
#include <cmath>
#include <set>
#include <iomanip>

#define x1 qwe
#define x2 mem
#define y2 kek
#define y1 cheburek

#define sqr(a) a * a

const int N = 200005;
const int MAX_NUM = 100001;
#define pi 3.14159265359

using namespace std;

int a[N], n, r;

bool used[N];
int changed[N];
int cnt[N];

vector<pair<int,int>> odd;
vector<pair<int,int>> even;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);

    cin >> n;

    int l = 1e9;

    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] += 100000;
        if (a[i] % 2 == 0) odd.push_back({a[i], i});
        else even.push_back({a[i], i});
    }

    sort(even.begin(), even.end());
    sort(odd.begin(), odd.end());

    int i = 0, j = odd.size() - 1;

    int ans = n;

    while(i < j) {

        if (odd[i].first == odd[j].first) break;

        a[odd[i].second] = a[odd[j].second] = (odd[i].first + odd[j].first) / 2;
        ans -= 2;
        i++;
        j--;
    }

    i = 0, j = even.size() - 1;

    while(i < j) {

        if (even[i].first == even[j].first) break;

        int can_do = (even[i].first + even[j].first) / 2;

        if (can_do % 2 == 0) {
            if (can_do + 1 != even[j].first) can_do++;
            if (can_do - 1 != even[i].first) can_do++;
        }

        a[even[i].second] = can_do;
        ans -= 2;
        i++;
        j--;
    }

    cout << ans << "\n";

    for(int i = 0; i < n; ++i) {
        cout << a[i] - 100000 << ' ';
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <fstream>
#include <memory>
#include <map>
#include <math.h>
#include <cmath>
#include <set>
#include <iomanip>

#define x1 qwe
#define x2 mem
#define y2 kek
#define y1 cheburek

#define sqr(a) a * a

const int N = 200005;
const int MAX_NUM = 100001;
#define pi 3.14159265359

using namespace std;

int a[N], n, r;

bool used[N];
int changed[N];
int cnt[N];

vector<pair<int,int>> odd;
vector<pair<int,int>> even;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);

    cin >> n;

    int l = 1e9, r = -1;

    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] += 100000;
        l = min(l, a[i]);
        r = max(r, a[i]);
    }

    if (r - l <= 1) {
        cout << n << "\n";
        for(int i = 0; i < n; ++i) {
            cout << a[i] - 100000 << " ";
        }
        return 0;
    }

    int cnt_l = 0, cnt_mid = 0, cnt_r;

    for(int i = 0; i < n; ++i) {
        if (a[i] == l){
            cnt_l++;
        } else if (a[i] == r) {
            cnt_r++;
        } else {
            cnt_mid++;
        }
    }

    int mid = (l + r) >> 1;

    cnt_l = cnt_r = min(cnt_l, cnt_r);

    if (cnt_mid % 2 == 1) cnt_mid--;

    bool ok = (cnt_l * 2 >= cnt_mid);

    cout << n - max(cnt_l * 2, cnt_mid) << "\n";

    for(int i = 0; i < n; ++i) {
        if (ok) {
            if (a[i] == l && cnt_l) {
                cnt_l--;
                a[i] = mid;
            }
            else if (a[i] == r && cnt_r) {
                cnt_r--;
                a[i] = mid;
            }
        } else if (a[i] == mid){
            if (!cnt_mid) continue;
            if (cnt_mid % 2 == 1) {
                a[i] = l;
            } else {
                a[i] = r;
            }
            cnt_mid--;
        }
    }

    for(int i = 0; i < n; ++i) {
        cout << a[i] - 100000 << ' ';
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <fstream>
#include <memory>
#include <map>
#include <math.h>
#include <cmath>
#include <set>
#include <iomanip>

#define x1 qwe
#define x2 mem
#define y2 kek
#define y1 cheburek

#define sqr(a) a * a

const int N = 200005;
const int MAX_NUM = 100001;
#define pi 3.14159265359

using namespace std;

int a[N], n, r;

bool used[N];
int changed[N];
int cnt[N];

vector<pair<int,int>> odd;
vector<pair<int,int>> even;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);

    cin >> n;

    int l = 1e9, r = -1;

    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] += 100000;
        l = min(l, a[i]);
        r = max(r, a[i]);
    }

    if (r - l <= 1) {
        cout << n << "\n";
        for(int i = 0; i < n; ++i) {
            cout << a[i] - 100000 << " ";
        }
        return 0;
    }

    int cnt_l = 0, cnt_mid = 0, cnt_r;

    for(int i = 0; i < n; ++i) {
        if (a[i] == l){
            cnt_l++;
        } else if (a[i] == r) {
            cnt_r++;
        } else {
            cnt_mid++;
        }
    }

    int mid = (l + r) >> 1;

    cnt_l = cnt_r = min(cnt_l, cnt_r);

    if (cnt_mid % 2 == 1) cnt_mid--;

    bool ok = (cnt_l * 2 > cnt_mid);

    cout << n - max(cnt_l * 2, cnt_mid) << "\n";

    for(int i = 0; i < n; ++i) {
        if (ok) {
            if (a[i] == l && cnt_l) {
                cnt_l--;
                a[i] = mid;
            }
            else if (a[i] == r && cnt_r) {
                cnt_r--;
                a[i] = mid;
            }
        } else if (a[i] == mid){
            if (!cnt_mid) continue;
            if (cnt_mid % 2 == 1) {
                a[i] = l;
            } else {
                a[i] = r;
            }
            cnt_mid--;
        }
    }

    for(int i = 0; i < n; ++i) {
        cout << a[i] - 100000 << ' ';
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <fstream>
#include <memory>
#include <map>
#include <math.h>
#include <cmath>
#include <set>
#include <iomanip>

#define x1 qwe
#define x2 mem
#define y2 kek
#define y1 cheburek

#define sqr(a) a * a

const int N = 200005;
const int MAX_NUM = 100001;
#define pi 3.14159265359

using namespace std;

int a[N], n, r;

bool used[N];
int changed[N];
int cnt[N];

vector<pair<int,int>> odd;
vector<pair<int,int>> even;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);

    cin >> n;

    int l = 1e9;

    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] += 100000;
        if (a[i] % 2 == 0) odd.push_back({a[i], i});
        else even.push_back({a[i], i});
    }

    sort(even.begin(), even.end());
    sort(odd.begin(), odd.end());

    int i = 0, j = odd.size() - 1;

    int ans = n;

    while(i < j) {

        if (odd[i].first == odd[j].first) break;

        a[odd[i].second] = a[odd[j].second] = (odd[i].first + odd[j].first) / 2;
        ans -= 2;
        i++;
        j--;
    }

    i = 0, j = even.size() - 1;

    while(i < j) {

        if (even[i].first == even[j].first) break;

        int can_do = (even[i].first + even[j].first) / 2;

        if (can_do % 2 == 0) {
            if (can_do + 1 != even[j].first) can_do++;
            if (can_do - 1 != even[i].first) can_do++;
        }

        a[even[i].second] = a[even[j].second] = (even[i].first + even[j].first) / 2;
        ans -= 2;
        i++;
        j--;
    }

    cout << ans << "\n";

    for(int i = 0; i < n; ++i) {
        cout << a[i] - 100000 << ' ';
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0;
#define ll long long

int n, x, y, z, mx, mn = (int)3e5, cnt[200002], delta = 100000;

void print(int a, int b, int c){
    for(int i = 0 ; i < a ; i++) cout << mn-delta << " ";
    for(int i = 0 ; i < b ; i++) cout << mn+1-delta << " ";
    for(int i = 0 ; i < c ; i++) cout << mn+2-delta << " ";
    cout << endl;
}
int cur(){
    int ret = max(0, cnt[mn]-x) + max(0, cnt[mn+1]-y) + max(0, cnt[mx]-z);
    return n-ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for(int i = 0 ; i < n && cin >> x ; i++)
        cnt[x+delta]++, mn = min(mn, x+delta), mx = max(mx, x+delta);
    if(mx-mn == 1){
        cout << n << endl;
        print(cnt[mn], cnt[mx], 0);
        return 0;
    }
    int ans = n+1;
    x = cnt[mn]; y = cnt[mn+1]; z = cnt[mx];
    int ansx = x, ansy = y, ansz = z;
    while(x && z){
        x--; z--; y += 2;
        if(cur() < ans){
            ans = cur();
            ansx = x;
            ansy = y;
            ansz = z;
        }
    }
    while(y >= 2){
        y -= 2; x++; z++;
        if(cur() < ans){
            ans = cur();
            ansx = x;
            ansy = y;
            ansz = z;
        }
    }
    x = ansx; y = ansy; z = ansz;
    cout << cur() << endl;
    print(ansx, ansy, ansz);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0;
#define ll long long

int n, x, y, z, mx, mn = (int)3e5, cnt[200002], delta = 100000;

void print(int a, int b, int c){
    for(int i = 0 ; i < a ; i++) cout << mn-delta << " ";
    for(int i = 0 ; i < b ; i++) cout << mn+1-delta << " ";
    for(int i = 0 ; i < c ; i++) cout << mn+2-delta << " ";
    cout << endl;
}
int cur(){
    int ret = max(0, cnt[mn]-x) + max(0, cnt[mn+1]-y) + max(0, cnt[mx]-z);
    return n-ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for(int i = 0 ; i < n && cin >> x ; i++)
        cnt[x+delta]++, mn = min(mn, x+delta), mx = max(mx, x+delta);
    if(mx == mn){
        cout << n << endl;
        print(cnt[mn], 0, 0);
        return 0;
    }
    if(mx-mn == 1){
        cout << n << endl;
        print(cnt[mn], cnt[mx], 0);
        return 0;
    }
    int ans = n+1;
    x = cnt[mn]; y = cnt[mn+1]; z = cnt[mx];
    int ansx = x, ansy = y, ansz = z;
    while(x && z){
        x--; z--; y += 2;
        if(cur() < ans){
            ans = cur();
            ansx = x;
            ansy = y;
            ansz = z;
        }
    }
    while(y >= 2){
        y -= 2; x++; z++;
        if(cur() < ans){
            ans = cur();
            ansx = x;
            ansy = y;
            ansz = z;
        }
    }
    x = ansx; y = ansy; z = ansz;
    cout << cur() << endl;
    print(ansx, ansy, ansz);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0;
#define ll long long

int n, x, y, z, mx, mn = (int)3e5, cnt[200002], delta = 100000;

void print(int a, int b, int c){
    for(int i = 0 ; i < a ; i++) cout << mn-delta << " ";
    for(int i = 0 ; i < b ; i++) cout << mn+1-delta << " ";
    for(int i = 0 ; i < c ; i++) cout << mn+2-delta << " ";
    cout << endl;
}
int cur(){
    int ret = max(0, cnt[mn]-x) + max(0, cnt[mn+1]-y) + max(0, cnt[mx]-z);
    return n-ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for(int i = 0 ; i < n && cin >> x ; i++)
        cnt[x+delta]++, mn = min(mn, x+delta), mx = max(mx, x+delta);
    if(mx-mn == 1){
        cout << n << endl;
        print(cnt[mn], cnt[mx], 0);
        return 0;
    }
    int ans = n+1;
    x = cnt[mn]; y = cnt[mn+1]; z = cnt[mx];
    int ansx, ansy, ansz;
    while(x && z){
        x--; z--; y += 2;
        if(cur() < ans){
            ans = cur();
            ansx = x;
            ansy = y;
            ansz = z;
        }
    }
    while(y >= 2){
        y -= 2; x++; y++;
        if(cur() < ans){
            ans = cur();
            ansx = x;
            ansy = y;
            ansz = z;
        }
    }
    x = ansx; y = ansy; z = ansz;
    cout << cur() << endl;
    print(ansx, ansy, ansz);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0;
#define ll long long

int n, x, y, z, mx, mn = (int)3e5, cnt[200002], delta = 100000;

void print(int a, int b, int c){
    for(int i = 0 ; i < a ; i++) cout << mn-delta << " ";
    for(int i = 0 ; i < b ; i++) cout << mn+1-delta << " ";
    for(int i = 0 ; i < c ; i++) cout << mn+2-delta << " ";
    cout << endl;
}
int cur(){
    int ret = max(0, cnt[mn]-x) + max(0, cnt[mn+1]-y) + max(0, cnt[mx]-z);
    return n-ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for(int i = 0 ; i < n && cin >> x ; i++)
        cnt[x+delta]++, mn = min(mn, x+delta), mx = max(mx, x+delta);
    if(mx-mn == 1){
        cout << n << endl;
        print(cnt[mn], cnt[mx], 0);
        return 0;
    }
    int ans = n+1;
    x = cnt[mn]; y = cnt[mn+1]; z = cnt[mx];
    int ansx, ansy, ansz;
    while(x && z){
        x--; z--; y += 2;
        if(cur() < ans){
            ans = cur();
            ansx = x;
            ansy = y;
            ansz = z;
        }
    }
    while(y >= 2){
        y -= 2; x++; y++;
        if(cur() < ans){
            ans = cur();
            ansx = x;
            ansy = y;
            ansz = z;
        }
    }
    cout << cur() << endl;
    print(ansx, ansy, ansz);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0;
#define ll long long

int n, x, y, z, mx, mn = (int)3e5, cnt[200002], delta = 100000;

void print(int a, int b, int c){
    for(int i = 0 ; i < a ; i++) cout << mn-delta << " ";
    for(int i = 0 ; i < b ; i++) cout << mn+1-delta << " ";
    for(int i = 0 ; i < c ; i++) cout << mn+2-delta << " ";
    cout << endl;
}
int cur(){
    int ret = max(0, cnt[mn]-x) + max(0, cnt[mn+1]-y) + max(0, cnt[mx]-z);
    return n-ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for(int i = 0 ; i < n && cin >> x ; i++)
        cnt[x+delta]++, mn = min(mn, x+delta), mx = max(mx, x+delta);
    if(mx-mn == 1){
        cout << n << endl;
        print(cnt[mn], cnt[mx], 0);
        return 0;
    }
    int ans = n+1;
    x = cnt[mn]; y = cnt[mn+1]; z = cnt[mx];
    int ansx, ansy, ansz;
    while(x && z){
        x--; z--; y += 2;
        if(cur() < ans){
            ans = cur();
            ansx = x;
            ansy = y;
            ansz = z;
        }
    }
    cout << cur() << endl;
    print(ansx, ansy, ansz);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0;
#define ll long long

int n, x, y, z, mx, mn = (int)3e5, cnt[200002], delta = 100000;

void print(int a, int b, int c){
    for(int i = 0 ; i < a ; i++) cout << mn-delta << " ";
    for(int i = 0 ; i < b ; i++) cout << mn+1-delta << " ";
    for(int i = 0 ; i < c ; i++) cout << mn+2-delta << " ";
    cout << endl;
}
int cur(){
    int ret = max(0, cnt[mn]-x) + max(0, cnt[mn+1]-y) + max(0, cnt[mx]-z);
    return n-ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for(int i = 0 ; i < n && cin >> x ; i++)
        cnt[x+delta]++, mn = min(mn, x+delta), mx = max(mx, x+delta);
    if(mx-mn == 1){
        cout << n << endl;
        print(cnt[mn], cnt[mx], 0);
        return 0;
    }
    int ans = n+1;
    x = cnt[mn]; y = cnt[mn+1]; z = cnt[mx];
    int ansx, ansy, ansz;
    while(x && z){
        x--; z--; y += 2;
        if(cur() < ans){
            ans = cur();
            ansx = x;
            ansy = y;
            ansz = z;
        }
    }
    while(y >= 2){
        y -= 2; x++; z++;
        if(cur() < ans){
            ans = cur();
            ansx = x;
            ansy = y;
            ansz = z;
        }
    }
    x = ansx; y = ansy; z = ansz;
    cout << cur() << endl;
    print(ansx, ansy, ansz);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0;
#define ll long long

int n, x, y, z, mx, mn = (int)3e5, cnt[200002], delta = 100000;

void print(int a, int b, int c){
    for(int i = 0 ; i < a ; i++) cout << mn-delta << " ";
    for(int i = 0 ; i < b ; i++) cout << mn+1-delta << " ";
    for(int i = 0 ; i < c ; i++) cout << mn+2-delta << " ";
    cout << endl;
}
int cur(){
    int ret = max(0, cnt[mn]-x) + max(0, cnt[mn+1]-y) + max(0, cnt[mx]-z);
    return n-ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for(int i = 0 ; i < n && cin >> x ; i++)
        cnt[x+delta]++, mn = min(mn, x+delta), mx = max(mx, x+delta);
    if(mx == mn){
        cout << n << endl;
        print(cnt[mn], 0, 0);
        return 0;
    }
    if(mx-mn == 1){
        cout << n << endl;
        print(cnt[mn], cnt[mx], 0);
        return 0;
    }
    int ans = n+1;
    x = cnt[mn]; y = cnt[mn+1]; z = cnt[mx];
    int ansx = x, ansy = y, ansz = z;
    x = 4; y = 1; z = 4;
    while(x && z){
        x--; z--; y += 2;
        if(cur() < ans){
            ans = cur();
            ansx = x;
            ansy = y;
            ansz = z;
        }
    }
    while(y >= 2){
        y -= 2; x++; z++;
        if(cur() < ans){
            ans = cur();
            ansx = x;
            ansy = y;
            ansz = z;
        }
    }
    x = ansx; y = ansy; z = ansz;
    cout << cur() << endl;
    print(ansx, ansy, ansz);
    return 0;
}


#include <bits/stdc++.h>
#define x first
#define y second
#define MaxN 100000
#define int64 long long
using namespace std;

int64 sum;
int64 T;
int res[MaxN+1];
int v[MaxN+1];
int t[MaxN+1];
int myfrec[3];
int frec[3];
int N;

int Get_MIN()
{
    int s = 1<<30;
    for(int i = 1; i <= N; ++i) s = min(s, t[i]);
    return s;
}

int main(){

    int i,j,k,pl,cnt,minn,minim=1<<30;

    scanf("%d",&N);
    for(i = 1; i <= N; ++i) scanf("%d",&v[i]);
    for(i = 1; i <= N; ++i) sum += v[i];

    sort(v+1, v+N+1);
    for(i = 1; i <= N; ++i) ++frec[ v[i] - v[1] ];

    pl = T = sum - 1LL * v[1] * N;
    for(i = 1; i <= N; ++i) t[i] = v[1];
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];

    minn = Get_MIN();
    for(i = 1; i <= N; ++i) ++myfrec[ t[i] - minn ];

    cnt = 0;
    for(i = 0; i < 3; ++i) cnt = cnt + min(myfrec[i], frec[i]);
    if(cnt < minim && T >= 0){
        minim = cnt;
        for(i = 1; i <= N; ++i) res[i] = t[i];
    }
/*
    pl = T = sum - 1LL * (v[1] + 1) * N;
    for(i = 1; i <= N; ++i) t[i] = v[1] + 1;
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];
    for(i = 0; i < 3; ++i) myfrec[i] = 0;
    minn = Get_MIN();
    for(i = 1; i <= N; ++i) ++myfrec[ t[i] - minn ];

    cnt = 0;
    for(i = 0; i < 3; ++i) cnt = cnt + min(myfrec[i], frec[i]);
    if(cnt < minim && T >= 0){
        minim = cnt;
        for(i = 1; i <= N; ++i) res[i] = t[i];
    }

    pl = T = sum - 1LL * v[1] * N;
    for(i = 1; i <= N; ++i) t[i] = v[1];
    for(i = 1; i <= N && pl >= 2; ++i, pl -= 2) t[i] += 2;
    if(pl) ++t[N];

    for(i = 0; i < 3; ++i) myfrec[i] = 0;
    minn = Get_MIN();
    for(i = 1; i <= N; ++i) ++myfrec[ t[i] - minn ];

    cnt = 0;
    for(i = 0; i < 3; ++i) cnt = cnt + min(myfrec[i], frec[i]);
    if(cnt < minim && T >= 0){
        minim = cnt;
        for(i = 1; i <= N; ++i) res[i] = t[i];
    }
*/
    printf("%d\n",minim);
    for(i = 1; i <= N; ++i) printf("%d ",res[i]);

return 0;
}


#include <bits/stdc++.h>
#define x first
#define y second
#define MaxN 100000
#define int64 long long
using namespace std;

int64 sum;
int64 T;
int res[MaxN+1];
int v[MaxN+1];
int t[MaxN+1];
int myfrec[3];
int frec[3];
int N;

int main(){

    int i,j,k,pl,cnt,minim=1<<30;

    scanf("%d",&N);
    for(i = 1; i <= N; ++i) scanf("%d",&v[i]);
    for(i = 1; i <= N; ++i) sum += v[i];

    sort(v+1, v+N+1);
    for(i = 1; i <= N; ++i) ++frec[ v[i] - v[1] ];

    for(i = 1; i <= N; ++i) t[i] = v[1];

    pl = T = sum - 1LL * v[1] * N;
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];
    for(i = 1; i <= N; ++i) ++myfrec[ t[i] ];

    cnt = 0;
    for(i = 0; i < 3; ++i) cnt = cnt + min(myfrec[i], frec[i]);
    if(cnt < minim && T >= 0){
        minim = cnt;
        for(i = 1; i <= N; ++i) res[i] = t[i];
    }

    pl = T = sum - 1LL * (v[1] + 1) * N;
    for(i = 1; i <= N; ++i) t[i] = v[1] + 1;
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];
    for(i = 0; i < 3; ++i) myfrec[i] = 0;
    for(i = 1; i <= N; ++i) ++myfrec[ t[i] ];

    cnt = 0;
    for(i = 0; i < 3; ++i) cnt = cnt + min(myfrec[i], frec[i]);
    if(cnt < minim && T >= 0){
        minim = cnt;
        for(i = 1; i <= N; ++i) res[i] = t[i];
    }

    pl = T = sum - 1LL * v[1] * N;
    for(i = 1; i <= N; ++i) t[i] = v[1];
    for(i = 1; i <= N && pl >= 2; ++i, pl -= 2) t[i] += 2;
    if(pl) ++t[N];

    for(i = 0; i < 3; ++i) myfrec[i] = 0;
    for(i = 1; i <= N; ++i) ++myfrec[ t[i] ];

    cnt = 0;
    for(i = 0; i < 3; ++i) cnt = cnt + min(myfrec[i], frec[i]);
    if(cnt < minim && T >= 0){
        minim = cnt;
        for(i = 1; i <= N; ++i) res[i] = t[i];
    }

    printf("%d\n",minim);
    for(i = 1; i <= N; ++i) printf("%d ",res[i]);

return 0;
}


#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

int main(){

    int i,A,B,x,y,res=1<<30;

    scanf("%d %d",&A,&B);

    if(A > B) swap(A, B);
    for(i = A; i <= B; ++i)
    {
        x = i-A;
        y = B-i;
        res = min(res, x*(x+1) / 2 + y * (y+1) / 2);
    }

    printf("%d\n",res);

return 0;
}


#include <bits/stdc++.h>
#define x first
#define y second
#define MaxN 100000
#define int64 long long
using namespace std;

int64 sum;
int64 T;
int res[MaxN+1];
int v[MaxN+1];
int t[MaxN+1];
int myfrec[3];
int frec[3];
int N;

int Get_MIN()
{
    int s = 1<<30;
    for(int i = 1; i <= N; ++i) s = min(s, t[i]);
    return s;
}

int main(){

    int i,j,k,pl,cnt,minn,minim=1<<30;

    scanf("%d",&N);
    for(i = 1; i <= N; ++i) scanf("%d",&v[i]);
    for(i = 1; i <= N; ++i) sum += v[i];

    sort(v+1, v+N+1);
    for(i = 1; i <= N; ++i) ++frec[ v[i] - v[1] ];

    pl = T = sum - 1LL * v[1] * N;
    for(i = 1; i <= N; ++i) t[i] = v[1];
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];

    minn = Get_MIN();
    for(i = 1; i <= N; ++i) ++myfrec[ t[i] - minn ];

    cnt = 0;
    for(i = 0; i < 3; ++i) cnt = cnt + min(myfrec[i], frec[i]);
    if(cnt < minim && T >= 0){
        minim = cnt;
        for(i = 1; i <= N; ++i) res[i] = t[i];
    }

    pl = T = sum - 1LL * (v[1] + 1) * N;
    for(i = 1; i <= N; ++i) t[i] = v[1] + 1;
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];
    for(i = 0; i < 3; ++i) myfrec[i] = 0;
    minn = Get_MIN();
    for(i = 1; i <= N; ++i) ++myfrec[ t[i] - minn ];

    cnt = 0;
    for(i = 0; i < 3; ++i) cnt = cnt + min(myfrec[i], frec[i]);
    if(cnt < minim && T >= 0){
        minim = cnt;
        for(i = 1; i <= N; ++i) res[i] = t[i];
    }

    pl = T = sum - 1LL * v[1] * N;
    for(i = 1; i <= N; ++i) t[i] = v[1];
    for(i = 1; i <= N && pl >= 2; ++i, pl -= 2) t[i] += 2;
    if(pl) ++t[N];

    for(i = 0; i < 3; ++i) myfrec[i] = 0;
    minn = Get_MIN();
    for(i = 1; i <= N; ++i) ++myfrec[ t[i] - minn ];

    cnt = 0;
    for(i = 0; i < 3; ++i) cnt = cnt + min(myfrec[i], frec[i]);
    if(cnt < minim && T >= 0){
        minim = cnt;
        for(i = 1; i <= N; ++i) res[i] = t[i];
    }

    printf("%d\n",minim);
    for(i = 1; i <= N; ++i) printf("%d ",res[i]);

return 0;
}


#include <bits/stdc++.h>
#define x first
#define y second
#define MaxN 100000
#define int64 long long
using namespace std;

int64 sum;
int64 T;
int res[MaxN+1];
int v[MaxN+1];
int t[MaxN+1];
int myfrec[3];
int frec[3];
int N;

int main(){

    int i,j,k,pl,cnt,minim=1<<30;

    scanf("%d",&N);
    for(i = 1; i <= N; ++i) scanf("%d",&v[i]);
    for(i = 1; i <= N; ++i) sum += v[i];

    sort(v+1, v+N+1);
    for(i = 1; i <= N; ++i) ++frec[ v[i] - v[1] ];

    for(i = 1; i <= N; ++i) t[i] = v[1];

    pl = T = sum - 1LL * v[1] * N;
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];
    for(i = 1; i <= N; ++i) ++myfrec[ t[i] ];

    cnt = 0;
    for(i = 0; i < 3; ++i) cnt = cnt + min(myfrec[i], frec[i]);
    if(cnt < minim && T >= 0){
        minim = cnt;
        for(i = 1; i <= N; ++i) res[i] = t[i];
    }

    pl = T = sum - 1LL * (v[1] + 1) * N;
    for(i = 1; i <= N; ++i) t[i] = v[1] + 1;
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];
    for(i = 1; i <= N && pl; ++i, --pl) ++t[i];
    for(i = 0; i < 3; ++i) myfrec[i] = 0;
    for(i = 1; i <= N; ++i) ++myfrec[ t[i] ];

    cnt = 0;
    for(i = 0; i < 3; ++i) cnt = cnt + min(myfrec[i], frec[i]);
    if(cnt < minim && T >= 0){
        minim = cnt;
        for(i = 1; i <= N; ++i) res[i] = t[i];
    }

    pl = T = sum - 1LL * v[1] * N;
    for(i = 1; i <= N; ++i) t[i] = v[1];
    for(i = 1; i <= N && pl >= 2; ++i, pl -= 2) t[i] += 2;
    if(pl) ++t[N];

    for(i = 0; i < 3; ++i) myfrec[i] = 0;
    for(i = 1; i <= N; ++i) ++myfrec[ t[i] ];

    cnt = 0;
    for(i = 0; i < 3; ++i) cnt = cnt + min(myfrec[i], frec[i]);
    if(cnt < minim && T >= 0){
        minim = cnt;
        for(i = 1; i <= N; ++i) res[i] = t[i];
    }

    for(i = 1; i <= N; ++i) printf("%d ",res[i]);

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int a[102000];
int b[102000];
map<int,int> mymap;
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		mymap[a[i]]++;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n/2;++i){
		if(a[n-i+1]-a[i]==2){
			a[i]++;
			a[n-i+1]--;
		}
	}
	int cnt=0;

	for(int i=1;i<=n;i++){
		if(mymap[a[i]]){
			cnt++;
			mymap[a[i]]--;
		}
	}
	cout<<cnt<<endl;
	for(int i=1;i<=n;++i){
		printf("%d%c",a[i],i==n?'\n':' ');
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int a[102000];
int b[102000];
map<int,int> mymap;
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		mymap[a[i]]++;
	}
	sort(a+1,a+1+n);
	for(int i=1;i*2<=n;++i){
		if(a[n-i+1]-a[i]==2){
			a[i]++;
			a[n-i+1]--;
		}
	}
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(mymap[a[i]]){
			cnt++;
			mymap[a[i]]--;
		}
	}
	cout<<cnt<<endl;
	for(int i=1;i<=n;++i){
		printf("%d%c",a[i],i==n?'\n':' ');
	}
	return 0;
}


// practice with kaiboy
import java.io.*;
import java.util.*;

public class CF931E extends PrintWriter {
	CF931E() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF931E o = new CF931E(); o.main(); o.flush();
	}

	static final int A = 26;
	void main() {
		byte[] cc = sc.next().getBytes();
		int n = cc.length;
		int[][][] kk = new int[A][n][A];
		int[] k1 = new int[A];
		for (int i = 0; i < n; i++) {
			int a = cc[i] - 'a';
			k1[a]++;
			for (int d = 1; d < n; d++) {
				int j = (i + d) % n;
				int b = cc[j] - 'a';
				kk[a][d][b]++;
			}
		}
		double p = 0;
		for (int a = 0; a < A; a++) {
			if (k1[a] == 0)
				continue;
			int u_ = 0, v_ = 1;
			for (int d = 1; d < n; d++) {
				int u = 0, v = 0;
				for (int b = 0; b < A; b++) {
					int k = kk[a][d][b];
					if (k == 1)
						u++;
					v += k;
				}
				if (u_ * v  < u * v_) {
					u_ = u; v_ = v;
				}
			}
			p += (double) k1[a] / n * u_ / v_;
		}
		println(p);
	}
}


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

//.define
//#define FILE_IN_OUT
#define RET(_x)                       return std::cout << (_x), 0;
#define all(_obj)                     std::begin(_obj), std::end(_obj)
#define fori(_iterator, _begin, _end) for (int _iterator = (_begin); _iterator < (_end); ++_iterator)
#define forr(_iterator, _begin, _end) for (int _iterator = (_begin); _iterator >= (_end); --_iterator)
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define ceilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>(std::size(_obj))
#define endl                          "\n"
template<typename Tp>
inline void outarr(Tp _array, const std::size_t _N, const char* _delim = " ") {
    Tp end = _array + _N;
    for (Tp current = _array; current != end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = int64_t;
using pii = std::pair<int, int>;
constexpr int INF = INT_MAX;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
int voc[5000][26];
int abc[26];
int used[26];

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin  ("input.txt",  std::ios::in);
    std::ofstream cout ("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    string s;
    cin >> s;
    int n = sz(s);

    loop(n) {
        ++abc[s[i] - 'a'];
    }

    int good = 0;
    int all = 0;
    fori(c, 'a', 'z') {
        if (abc[c - 'a'] == 0) {
            continue;
        }
        all += abc[c - 'a'];
        memset(voc, -1, sizeof(voc));
        memset(used, 0, sizeof(used));
        loop(n) {
            if (s[i] != c) {
                continue;
            }
            fori(j, 1, n) {
                int y = s[(i + j) % n] - 'a';
                if (voc[j - 1][y] > -1) {
                    voc[j - 1][y] = -2;
                } else if (voc[j - 1][y] == -1) {
                    voc[j - 1][y] = s[i] - 'a';
                }
            }
        }
        int uu = INF;
        loop(n) {
            int cur = 0;
            fori(j, 0, 26) {
                if (voc[i][j] > -1) {
                    ++cur;
                }
            }
            if (cur) {
                uu = min(uu, cur);
            }
        }
        if (uu != INF) {
            good += uu;
        }
    }

    cout << fixed << setprecision(15) << 1.0 * good / all << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}


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

//.define
//#define FILE_IN_OUT
#define RET(_x)                       return std::cout << (_x), 0;
#define all(_obj)                     std::begin(_obj), std::end(_obj)
#define fori(_iterator, _begin, _end) for (int _iterator = (_begin); _iterator < (_end); ++_iterator)
#define forr(_iterator, _begin, _end) for (int _iterator = (_begin); _iterator >= (_end); --_iterator)
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define ceilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>(std::size(_obj))
#define endl                          "\n"
template<typename Tp>
inline void outarr(Tp _array, const std::size_t _N, const char* _delim = " ") {
    Tp end = _array + _N;
    for (Tp current = _array; current != end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = int64_t;
using pii = std::pair<int, int>;
constexpr int INF = INT_MAX;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
int voc[5000][26];
int abc[26];
int used[26];

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin  ("input.txt",  std::ios::in);
    std::ofstream cout ("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    string s;
    cin >> s;
    int n = sz(s);

    loop(n) {
        ++abc[s[i] - 'a'];
    }

    int good = 0;
    int all = 0;
    fori(c, 'a', 'z') {
        if (abc[c - 'a'] == 0) {
            continue;
        }
        all += abc[c - 'a'];
        memset(voc, -1, sizeof(voc));
        memset(used, 0, sizeof(used));
        loop(n) {
            if (s[i] != c) {
                continue;
            }
            fori(j, 1, n) {
                int y = s[(i + j) % n] - 'a';
                if (voc[j - 1][y] > -1) {
                    voc[j - 1][y] = -2;
                } else if (voc[j - 1][y] == -1) {
                    voc[j - 1][y] = s[i] - 'a';
                }
            }
        }
        int uu = 0;
        loop(n) {
            int cur = 0;
            fori(j, 0, 26) {
                if (voc[i][j] > -1) {
                    ++cur;
                }
            }
            uu = max(uu, cur);
        }
        good += uu;
    }

    cout << fixed << setprecision(15) << 1.0 * good / all << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}


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

//.define
//#define FILE_IN_OUT
#define RET(_x)                       return std::cout << (_x), 0;
#define all(_obj)                     std::begin(_obj), std::end(_obj)
#define fori(_iterator, _begin, _end) for (int _iterator = (_begin); _iterator < (_end); ++_iterator)
#define forr(_iterator, _begin, _end) for (int _iterator = (_begin); _iterator >= (_end); --_iterator)
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define ceilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>(std::size(_obj))
#define endl                          "\n"
template<typename Tp>
inline void outarr(Tp _array, const std::size_t _N, const char* _delim = " ") {
    Tp end = _array + _N;
    for (Tp current = _array; current != end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = int64_t;
using pii = std::pair<int, int>;
constexpr int INF = INT_MAX;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
int voc[5000][26];
int abc[26];
char used[5003];

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin  ("input.txt",  std::ios::in);
    std::ofstream cout ("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    string s;
    cin >> s;
    int n = sz(s);

    loop(n) {
        ++abc[s[i] - 'a'];
    }

    int good = 0;
    int all = 0;
    fori(c, 'a', 'z') {
        if (abc[c - 'a'] == 0) {
            continue;
        }
        all += abc[c - 'a'];
        memset(voc, -1, sizeof(voc));
        memset(used, 0, sizeof(used));
        loop(n) {
            if (s[i] != c) {
                continue;
            }
            fori(j, 1, n) {
                int y = s[(i + j) % n] - 'a';
                if (voc[j - 1][y] > -1) {
                    voc[j - 1][y] = -2;
                } else if (voc[j - 1][y] == -1) {
                    voc[j - 1][y] = i;
                }
            }
        }
        loop(n) {
            fori(j, 0, 26) {
                if (voc[i][j] > -1 && !used[voc[i][j]]) {
                    ++good;
                    used[voc[i][j]] = true;
                }
            }
        }
    }

    cout << fixed << setprecision(15) << 1.0 * good / all << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}


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

//.define
//#define FILE_IN_OUT
#define RET(_x)                       return std::cout << (_x), 0;
#define all(_obj)                     std::begin(_obj), std::end(_obj)
#define fori(_iterator, _begin, _end) for (int _iterator = (_begin); _iterator < (_end); ++_iterator)
#define forr(_iterator, _begin, _end) for (int _iterator = (_begin); _iterator >= (_end); --_iterator)
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define ceilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>(std::size(_obj))
#define endl                          "\n"
template<typename Tp>
inline void outarr(Tp _array, const std::size_t _N, const char* _delim = " ") {
    Tp end = _array + _N;
    for (Tp current = _array; current != end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = int64_t;
using pii = std::pair<int, int>;
constexpr int INF = INT_MAX;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
int voc[5000][26];
int abc[26];

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin  ("input.txt",  std::ios::in);
    std::ofstream cout ("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    string s;
    cin >> s;
    int n = sz(s);

    loop(n) {
        ++abc[s[i] - 'a'];
    }

    int good = 0;
    int all = 0;
    fori(c, 'a', 'z' + 1) {
        if (abc[c - 'a'] == 0) {
            continue;
        }
        all += abc[c - 'a'];
        memset(voc, -1, sizeof(voc));
        loop(n) {
            if (s[i] != c) {
                continue;
            }
            fori(j, 1, n) {
                int y = s[(i + j) % n] - 'a';
                if (voc[j - 1][y] > -1) {
                    voc[j - 1][y] = -2;
                } else if (voc[j - 1][y] == -1) {
                    voc[j - 1][y] = s[i] - 'a';
                }
            }
        }
        int uu = 0;
        loop(n - 1) {
            int cur = 0;
            fori(j, 0, 26) {
                if (voc[i][j] > -1) {
                    ++cur;
                }
            }
            uu = max(uu, cur);
        }
        good += uu;
    }

    cout << fixed << setprecision(15) << 1.0 * good / all << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}


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

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define forn(i, n) for (int i = 0; i < n; i++)
#define fin(ds) for (auto &v : ds) cin >> v;
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define nl '\n'

typedef long long ll;

const int eng = 'z' + 1;
const int N = 5007;

int counts[eng - 'a'] = { 0 };
int dat[eng - 'a'][N][eng - 'a'] = { 0 };

signed main() { _
    string s; cin >> s;
    int n = (int)s.size();

    forn(i, n) {
        char c = s[i];
        counts[c - 'a']++;
        for (int j = (i + 1) % n, x = 0; x < n; j = (j + 1) % n, x++)
            dat[c - 'a'][x][s[j] - 'a']++;
    }

    double prob = 0;
    for (int c = 'a'; c < eng; c++) {
        double p_max = 0;
        double count = counts[c - 'a'];

        if (count > 0) {
            for (int x = 0; x < n; x++) {
                double p_loc = 0;

                for (int d = 'a'; d < eng; d++)
                    if (dat[c - 'a'][x][d - 'a'] == 1)
                        p_loc++;

                p_max = max(p_max, p_loc);
            }

            prob += (p_max / count) * (count / n);
        }
    }

    cout << prob << endl;
}


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

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define forn(i, n) for (int i = 0; i < n; i++)
#define fin(ds) for (auto &v : ds) cin >> v;
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define nl '\n'

typedef long long ll;

const int eng = 'z' + 1;

signed main() { _
    string s; cin >> s;
    int n = (int)s.size();
    multiset<char> data[eng][n];

    forn(i, n) {
        char c = s[i];
        for (int j = (i + 1) % n, x = 0; x < n; j = (j + 1) % n, x++) {
            data[c][x].insert(s[j]);
        }
    }

    double prob = 0;
    for (int c = 'a'; c <= 'z'; c++) {
        double p_max = 0;
        double count = data[c][0].size();

        if (count > 0) {
            for (int x = 0; x < n; x++) {
                double p_loc = 0;
                for (char d : data[c][x]) {
                    if (data[c][x].count(d) == 1) {
                        p_loc++;
                    }
                }
                p_max = max(p_max, p_loc);
            }

            prob += ((p_max / count) * (count / n));
        }
    }

    cout << prob << endl;
}


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

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define forn(i, n) for (int i = 0; i < n; i++)
#define fin(ds) for (auto &v : ds) cin >> v;
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define nl '\n'

typedef long long ll;

const int eng = 'z' + 1;
const int N = 5007;

int counts[eng] = { 0 };
int dat[eng][N][eng] = { 0 };

signed main() { _
    string s; cin >> s;
    int n = (int)s.size();

    forn(i, n) {
        char c = s[i];
        counts[c]++;
        for (int j = (i + 1) % n, x = 0; x < n; j = (j + 1) % n, x++)
            dat[c][x][s[j]]++;
    }

    double prob = 0;
    for (int c = 'a'; c < eng; c++) {
        double p_max = 0;
        double count = counts[c];

        if (count > 0) {
            for (int x = 0; x < n; x++) {
                double p_loc = 0;

                for (int d = 'a'; d < eng; d++)
                    if (dat[c][x][d] == 1)
                        p_loc++;

                p_max = max(p_max, p_loc);
            }

            prob += (p_max / count) * (count / n);
        }
    }

    cout << prob << endl;
}


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

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define forn(i, n) for (int i = 0; i < n; i++)
#define fin(ds) for (auto &v : ds) cin >> v;
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define nl '\n'

typedef long long ll;

const int eng = 'z' + 1;

signed main() { _
    string s; cin >> s;
    int n = (int)s.size();

    double counts[eng] = { 0 };
    map<char, int> data[eng][n];

    forn(i, n) {
        char c = s[i];
        counts[c]++;
        for (int j = (i + 1) % n, x = 0; x < n; j = (j + 1) % n, x++) {
            data[c][x][s[j]]++;
        }
    }

    double prob = 0;
    for (int c = 'a'; c <= 'z'; c++) {
        double p_max = 0;
        double count = counts[c];

        if (count > 0) {
            for (int x = 0; x < n; x++) {
                double p_loc = 0;

                for (int d = 'a'; d <= 'z'; d++)
                    if (data[c][x][d] == 1)
                        p_loc++;

                p_max = max(p_max, p_loc);
            }

            prob += ((p_max / count) * (count / n));
        }
    }

    cout << prob << endl;
}


#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
//#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e8;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=200005;

void solve()
{

    string s;
    cin>>s;
    int n=s.length();
    ldb ans=0;
    s=s+s;
    int fr[26]={0};
    for(int i=0;i<n;i++)
     fr[s[i]-'a']++;
    for(char ch='a';ch<='z';ch++)
    {
        int mx[n+1]={0};int f[n+1][26];
        memset(f,0,sizeof(f));
        if(!fr[ch-'a'])
            continue;
        for(int i=0;i<n;i++)
        {
            if(s[i]==ch)
            {
                for(int j=1;j<n;j++)
                {
                    f[j][s[i+j]-'a']++;
                    //mx[j]=max(mx[j],f[j][s[i+j]-'a']);
                }
            }
        }
        int Cnt=0;
        for(int j=1;j<n;j++)
        {
            int cnt=0;
            for(int k=0;k<26;k++)
                if(f[j][k]==1)
                {
                    cnt++;
                }
            Cnt=max(Cnt,cnt);
        }
            ans=ans+(ldb)Cnt/n;
        /*
            for(int i=1;i<n;i++)
            {
                ldb z=(ldb)fr[ch-'a']/n;
                z=z/mx[i];
                ans=max(ans,z);
            }
         */

    }
    cout<<setprecision(10);
    cout<<ans<<endl;

}

int32_t main()
{

    IOS;

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


#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long  //comment it out when MLE
//# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000009
# define pi acos(-1)
# define fi first
# define se second
using namespace std;

signed main()
{
    gok
    string s;
    cin>>s;
    int n = s.size();
    bool vis[26]={false};
    vector<int> v[26];
    for(int i=0;i<n;i++)
    {
        v[s[i]-'a'].push_back(i);
    }
    int an=0;
    for(int i=0;i<26;i++)
    {
        int mx=0;
        if(v[i].size()>0)
        {
            for(int k=0;k<n;k++){
                    int fr[26]={0};
            memset(fr,0,sizeof(fr));
            for(int j=0;j<v[i].size();j++)
            {
                fr[s[(v[i][j]+k)%n]-'a']++;
            }
            int cc=0;
            for(int i=0;i<26;i++)
            {
                if(fr[i]==1)
                    cc++;
            }
           // cout<<cc<<" ";
            mx=max(mx,cc);
            }

        }
        an += mx;
    }
   cout<<an<<endl;
   cout<<fixed<<setprecision(10)<<(an/((double)n))*1.000;

      return 0;
    }


#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long  //comment it out when MLE
//# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000009
# define pi acos(-1)
# define fi first
# define se second
using namespace std;

signed main()
{
    gok
    string s;
    cin>>s;
    int n = s.size();
    bool vis[26]={false};
    vector<int> v[26];
    for(int i=0;i<n;i++)
    {
        v[s[i]-'a'].push_back(i);
    }
    int an=0;
    for(int i=0;i<26;i++)
    {
        int mx=0;
        if(v[i].size()>0)
        {
            for(int k=0;k<n;k++){
                    int fr[26]={0};
            memset(fr,0,sizeof(fr));
            for(int j=0;j<v[i].size();j++)
            {
                fr[s[(v[i][j]+k)%n]-'a']++;
            }
            int cc=0;
            for(int i=0;i<26;i++)
            {
                if(fr[i]==1)
                    cc++;
            }
           // cout<<cc<<" ";
            mx=max(mx,cc);
            }

        }
        an += mx;
    }
   //cout<<an<<endl;
   cout<<fixed<<setprecision(10)<<(an/((double)n))*1.000;

      return 0;
    }


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

#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
	string s;
	cin>>s;
	int l=s.size();
	s=s+s;
	ll cnt1=0,tot=0;
	vi start[26];
	fr(i,0,l){
		start[s[i]-'a'].pb(i);
	}
	int cnt[26]={0};
	int mark[l+1]={0};
	fr(i,0,26){
		int cntemp=0;
		fr(j,1,l){
			int temp=0;
			memset(cnt,0,sizeof(cnt));
			for(auto x: start[i]){
				cnt[s[x+j]-'a']++;
			}
			fr(k,0,26){
				if(cnt[k]==1){
					temp++;
				}
			}
			cntemp=max(cntemp,temp);
		}
		cnt1+=cntemp;
	}
	ld num=cnt1;
	ld den=l;
	cout<<fixed<<setprecision(12)<<(num/den)<<endl;
	return;
}

int main()
{
	boost();

	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}


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

#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
	string s;
	cin>>s;
	int l=s.size();
	s=s+s;
	ll cnt1=0;
	vi start[26];
	fr(i,0,l){
		start[s[i]-'a'].pb(i);
	}
	int cnt[26]={0};
	int mark[l+1]={0};
	int from[26]={0};
	fr(i,0,26){
		fr(j,1,l){
			memset(cnt,0,sizeof(cnt));
			memset(from,0,sizeof(from));
			for(auto x: start[i]){
				if(mark[x]==1)
					continue;
				from[s[x+j]-'a']=x;
				cnt[s[x+j]-'a']++;
			}
			fr(k,0,26){
				if(cnt[k]==1){
					mark[from[k]]=1;
					cnt1++;
				}
			}
		}
	}
	ld num=cnt1;
	ld den=l;
	cout<<fixed<<setprecision(12)<<(num/den)<<endl;
	return;
}

int main()
{
	boost();

	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}


#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>

#define SS ;
typedef long long ll;
using namespace std;
int s[5000];
int main() {
	string ss;
	cin >> ss;
	for (size_t i = 0; i < ss.size(); i++) {
		s[i] = ss[i] - 'a';
	}
	int l = ss.size();
	int count[26] = { 0 };
	for (int shif = 0; shif < l; shif++) {
		int b[26][26] = { 0 };
		int c[26] = { 0 };
		for (auto j = 0; j < l; j++)
		{
			int index = j + shif;
			if (index >= l)
				index -= l;
			b[s[j]][s[index]]++;
		}
		for (int j = 0; j < 26; j++)
			for (int k = 0; k < 26; k++)
			{
				if (b[j][k] == 1)
					c[j]++;
			}
		for (int j = 0; j < 26; j++)
		{
			if (count[j] < c[j])
				count[j] = c[j];
		}
	}
	int q = 0;
	for (size_t j = 0; j < 26; j++)
	{
		q += count[j];
	}
	cout << setprecision(8) << double(q) / l << endl;
	SS;
	return 0;
}


#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>

#define SS system("pause");
typedef long long ll;
using namespace std;
int a[26];
int s[5000];
int main() {
	string ss;
	cin >> ss;
	int l = ss.size();

	for (size_t i = 0; i < l; i++){
		s[i] = ss[i] - 'a';
		a[s[i]]++;
	}
	int q = 0;
	int count[26] = {0};
	for (int shif = 0; shif < l; shif++){
		int b[26 * 26] = { 0 };
		int c[26] = { 0 };
		for (int j=0;j<l;j++)
		{
			int index = j + shif;
			if (index >= l)
				index -= l;
			b[s[index]+s[j]*26]++;
		}
		for (int j = 0; j < 26*26; j++)
			if (b[j] == 1)
				c[j/26]++;
		for (size_t j = 0; j < 26; j++)
			count[j] = max(count[j], c[j]);
	}
	cout << setprecision(8) << double(q)/l << endl;
	SS;
	return 0;
}


#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
#include <fstream>
#include <tuple>
#include <iomanip>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define all(a) a.begin(), a.end()
#define sz(a) (int(a.size()))
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define g(a, b) get<a> (b)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pt;

const ll MAX_N = 2e5;

int main(){
    int n, l, x, y;
    cin >> n >> l >> x >> y;
    vector <int> st(n);
    for (int i = 0; i < n; i++){
        scanf("%d", &st[i]);
    }
    bool pravda = false;
    for (int i = 0; i < n; i++){
        int kek = lower_bound(st.begin(), st.end(), st[i] + x) - st.begin();
        if (st[kek] - st[i] == x) {pravda = true; break;}
    }
    if (pravda){
        for (int i = 0; i < n; i++){
        int kek = lower_bound(st.begin(), st.end(), st[i] + y) - st.begin();
        if (st[kek] - st[i] == y) {cout << 0; return 0;}
        }
        cout << 1 << endl << y;
        return 0;
    }
    pravda = false;
    for (int i = 0; i < n; i++){
        int kek = lower_bound(st.begin(), st.end(), st[i] + y) - st.begin();
        if (st[kek] - st[i] == y) {pravda = true; break;}
        }
    if (pravda) {cout << 1 << endl << x; return 0;}
    for (int i = 0; i < n - 1; i++){
        int kek = lower_bound(st.begin(), st.end(), st[i] + y + x) - st.begin();
        if (st[kek] - st[i] - x == y){cout << 1 << endl << st[i] + x ;return 0;}
    }
    for (int i = 1; i < n; i++){
        if (st[i] - x < 0)continue;
        int kek = lower_bound(st.begin(), st.end(), st[i] + y - x) - st.begin();
        if (st[kek] - st[i] + x == y){cout << 1 << endl << st[i] - x ;return 0;}
    }
    for (int i = 1; i < n; i++){
        if (st[i] - x - y < 0)continue;
        int kek = lower_bound(st.begin(), st.end(), st[i] - y - x) - st.begin();
        if (st[i] - x - st[kek] == y){cout << 1 << endl << st[i] - x ;return 0;}
    }
    for (int i = 1; i < n; i++){
        if (st[i] + x - y < 0)continue;
        int kek = lower_bound(st.begin(), st.end(), st[i] - y + x) - st.begin();
        if (st[i] + x - st[kek] == y){cout << 1 << endl << st[i] + x ;return 0;}
        cout << st[kek] << endl;
    }
    cout << 2 << endl << x << " " << y;
    return 0;
}


#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
#include <fstream>
#include <tuple>
#include <iomanip>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define all(a) a.begin(), a.end()
#define sz(a) (int(a.size()))
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define g(a, b) get<a> (b)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pt;

const ll MAX_N = 2e5;

int main(){
    int n, l, x, y;
    cin >> n >> l >> x >> y;
    vector <int> st(n);
    for (int i = 0; i < n; i++){
        scanf("%d", &st[i]);
    }
    bool pravda = false;
    for (int i = 0; i < n; i++){
        int kek = lower_bound(st.begin(), st.end(), st[i] + x) - st.begin();
        if (st[kek] - st[i] == x) {pravda = true; break;}
    }
    if (pravda){
        for (int i = 0; i < n; i++){
        int kek = lower_bound(st.begin(), st.end(), st[i] + y) - st.begin();
        if (st[kek] - st[i] == y) {cout << 0; return 0;}
        }
        cout << 1 << endl << y;
        return 0;
    }
    pravda = false;
    for (int i = 0; i < n; i++){
        int kek = lower_bound(st.begin(), st.end(), st[i] + y) - st.begin();
        if (st[kek] - st[i] == y) {pravda = true; break;}
        }
    if (pravda) {cout << 1 << endl << x; return 0;}
    for (int i = 0; i < n; i++){
        int kek = lower_bound(st.begin(), st.end(), st[i] + y + x) - st.begin();
        if (st[kek] - x == y){cout << 1 << endl << x ;return 0;}
    }
    cout << 2 << endl << x << " " << y;
    return 0;
}