#include<set>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 200000;
int arr[MAXN + 5];
struct segtree{
	#define lch (x<<1)
	#define rch (x<<1|1)
	struct node{
		int l, r;
		int tg, cmn;
		int lmx, rmx, mx, ans, cnt;
	}t[4*MAXN + 5];
	void pushup(int x) {
		t[x].mx = max(t[lch].mx, t[rch].mx);
		t[x].cmn = min(t[lch].cmn, t[rch].cmn);

		if( t[x].cmn == t[lch].cmn )
			t[x].lmx = t[lch].lmx;
		else t[x].lmx = max(t[lch].mx, t[rch].lmx);

		if( t[x].cmn == t[rch].cmn )
			t[x].rmx = t[rch].rmx;
		else t[x].rmx = max(t[rch].mx, t[lch].rmx);

		if( t[x].cmn != t[rch].cmn ) {
			t[x].ans = t[lch].ans;
			t[x].cnt = t[lch].cnt + t[rch].r - t[rch].l + 1;
		}
		else if( t[x].cmn != t[lch].cmn ) {
			t[x].ans = t[rch].ans;
			t[x].cnt = t[rch].cnt + t[lch].r - t[lch].l + 1;
		}
		else {
			t[x].ans = t[lch].ans + t[rch].ans;
			t[x].cnt = t[lch].cnt + t[rch].cnt;
			if( t[lch].rmx != -1 || t[rch].lmx != -1 )
				t[x].ans += max(t[lch].rmx, t[rch].lmx), t[x].cnt++;
		}

	}
	void pushdown(int x) {
		if( t[x].tg ) {
			t[lch].tg += t[x].tg, t[rch].tg += t[x].tg;
			t[lch].cmn += t[x].tg, t[rch].cmn += t[x].tg;
			t[x].tg = 0;
		}
	}
	void build(int x, int l, int r) {
		t[x].l = l, t[x].r = r, t[x].tg = 0, t[x].ans = 0;
		if( l == r ) {
			t[x].cmn = 0, t[x].lmx = t[x].rmx = -1, t[x].mx = max(arr[l], arr[l + 1]);
			return ;
		}
		int mid = (l + r) >> 1;
		build(lch, l, mid), build(rch, mid + 1, r);
		pushup(x);
	}
	void update(int x, int p) {
		if( t[x].l > p || t[x].r < p )
			return ;
		if( t[x].l == t[x].r ) {
			t[x].mx = max(arr[p], arr[p + 1]);
			return ;
		}
		pushdown(x);
		update(lch, p);
		update(rch, p);
		pushup(x);
	}
	void modify(int x, int l, int r, int d) {
		if( l <= t[x].l && t[x].r <= r ) {
			t[x].tg += d, t[x].cmn += d;
			return ;
		}
		if( l > t[x].r || r < t[x].l )
			return ;
		pushdown(x);
		modify(lch, l, r, d);
		modify(rch, l, r, d);
		pushup(x);
	}
}T;
set<int>st[MAXN + 5];
int a[MAXN + 5], n, q;
void update(int p) {T.update(1, p - 1), T.update(1, p);}
void remove(int x) {
	int l = *st[a[x]].begin(), r = *st[a[x]].rbegin();
	T.modify(1, l, r - 1, -1), arr[l] = 0, update(l);
	st[a[x]].erase(x);
	if( !st[a[x]].empty() ) {
		int l = *st[a[x]].begin(), r = *st[a[x]].rbegin();
		T.modify(1, l, r - 1, 1), arr[l] = st[a[x]].size(), update(l);
	}
}
void add(int x) {
	if( !st[a[x]].empty() ) {
		int l = *st[a[x]].begin(), r = *st[a[x]].rbegin();
		T.modify(1, l, r - 1, -1), arr[l] = 0, update(l);
	}
	st[a[x]].insert(x);
	int l = *st[a[x]].begin(), r = *st[a[x]].rbegin();
	T.modify(1, l, r - 1, 1), arr[l] = st[a[x]].size(), update(l);
}
int main() {
	scanf("%d%d", &n, &q);
	for(int i=1;i<=n;i++)
		scanf("%d", &a[i]);
	T.build(1, 0, n);
	for(int i=1;i<=n;i++) add(i);
	printf("%d\n", T.t[1].cnt - T.t[1].ans);
	for(int i=1;i<=q;i++) {
		int it, xt; scanf("%d%d", &it, &xt);
		remove(it), a[it] = xt, add(it);
		printf("%d\n", T.t[1].cnt - T.t[1].ans);
	}
}


#include<set>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 200000;
int arr[MAXN + 5];
struct segtree{
	#define lch (x<<1)
	#define rch (x<<1|1)
	struct node{
		int l, r;
		int tg, cmn;
		int lmx, rmx, mx, ans, cnt;
	}t[4*MAXN + 5];
	void pushup(int x) {
		t[x].mx = max(t[lch].mx, t[rch].mx);
		t[x].cmn = min(t[lch].cmn, t[rch].cmn);

		if( t[x].cmn == t[lch].cmn )
			t[x].lmx = t[lch].lmx;
		else t[x].lmx = max(t[lch].mx, t[rch].lmx);

		if( t[x].cmn == t[rch].cmn )
			t[x].rmx = t[rch].rmx;
		else t[x].rmx = max(t[rch].mx, t[lch].rmx);

		if( t[x].cmn != t[rch].cmn ) {
			t[x].ans = t[lch].ans;
			t[x].cnt = t[lch].cnt + t[rch].r - t[rch].l + 1;
		}
		else if( t[x].cmn != t[lch].cmn ) {
			t[x].ans = t[rch].ans;
			t[x].cnt = t[rch].cnt + t[lch].r - t[lch].l + 1;
		}
		else {
			t[x].ans = t[lch].ans + t[rch].ans;
			if( t[lch].rmx != -1 || t[rch].lmx != -1 )
				t[x].ans += max(t[lch].rmx, t[rch].lmx);
			t[x].cnt = t[lch].cnt + t[rch].cnt;
		}

	}
	void pushdown(int x) {
		if( t[x].tg ) {
			t[lch].tg += t[x].tg, t[rch].tg += t[x].tg;
			t[lch].cmn += t[x].tg, t[rch].cmn += t[x].tg;
			t[x].tg = 0;
		}
	}
	void build(int x, int l, int r) {
		t[x].l = l, t[x].r = r, t[x].tg = 0, t[x].ans = 0;
		if( l == r ) {
			t[x].cmn = 0, t[x].lmx = t[x].rmx = -1, t[x].mx = max(arr[l], arr[l + 1]);
			return ;
		}
		int mid = (l + r) >> 1;
		build(lch, l, mid), build(rch, mid + 1, r);
		pushup(x);
	}
	void update(int x, int p) {
		if( t[x].l > p || t[x].r < p )
			return ;
		if( t[x].l == t[x].r ) {
			t[x].mx = max(arr[p], arr[p + 1]);
			return ;
		}
		pushdown(x);
		update(lch, p);
		update(rch, p);
		pushup(x);
	}
	void modify(int x, int l, int r, int d) {
		if( l <= t[x].l && t[x].r <= r ) {
			t[x].tg += d, t[x].cmn += d;
			return ;
		}
		if( l > t[x].r || r < t[x].l )
			return ;
		pushdown(x);
		modify(lch, l, r, d);
		modify(rch, l, r, d);
		pushup(x);
	}
}T;
set<int>st[MAXN + 5];
int a[MAXN + 5], n, q;
void update(int p) {T.update(1, p - 1), T.update(1, p);}
void remove(int x) {
	int l = *st[a[x]].begin(), r = *st[a[x]].rbegin();
	T.modify(1, l, r - 1, -1), arr[l] = 0, update(l);
	st[a[x]].erase(x);
	if( !st[a[x]].empty() ) {
		int l = *st[a[x]].begin(), r = *st[a[x]].rbegin();
		T.modify(1, l, r - 1, 1), arr[l] = st[a[x]].size(), update(l);
	}
}
void add(int x) {
	if( !st[a[x]].empty() ) {
		int l = *st[a[x]].begin(), r = *st[a[x]].rbegin();
		T.modify(1, l, r - 1, -1), arr[l] = 0, update(l);
	}
	st[a[x]].insert(x);
	int l = *st[a[x]].begin(), r = *st[a[x]].rbegin();
	T.modify(1, l, r - 1, 1), arr[l] = st[a[x]].size(), update(l);
}
int main() {
	scanf("%d%d", &n, &q);
	for(int i=1;i<=n;i++)
		scanf("%d", &a[i]);
	T.build(1, 0, n);
	for(int i=1;i<=n;i++) add(i);
	printf("%d\n", T.t[1].cnt + 1 - T.t[1].ans);
	for(int i=1;i<=q;i++) {
		int it, xt; scanf("%d%d", &it, &xt);
		remove(it), a[it] = xt, add(it);
		printf("%d\n", T.t[1].cnt + 1 - T.t[1].ans);
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  input(a) for(auto &it:a) cin>>it;
#define output(a) for(auto it:a) cout<<it<<" ";
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vpi vector<pair<int,int>>
const ll MOD=1e9+7;
# define MAXINT 1000*1000*1000
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin) ;
        freopen("output.txt" , "w" , stdout) ;
    #endif
    int n,i,j;
    cin>>n;
    vector<string>a(n);
    input(a);
    for(i=0;i<n;++i)
    {
        for(j=0;j<n;++j)
        {
            if(a[i][j]=='.')
            {
                a[i][j]='#';
                if(i+2<n && j-1>=0 && j+1<n)
                {
                    cout<<"NO";
                    return 0;
                }
                if(a[i+1][j]=='.' && a[i+1][j-1]=='.' && a[i+1][j+1]=='.' && a[i+2][j]=='.')
                {
                    a[i+1][j]='#';
                    a[i+2][j]='#';
                    a[i+1][j-1]='#';
                    a[i+1][j+1]='#';
                }
                else
                {
                    cout<<"NO";
                    return 0;
                }
            }

        }
    }
    cout<<"YES";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  input(a) for(auto &it:a) cin>>it;
#define output(a) for(auto it:a) cout<<it<<" ";
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vpi vector<pair<int,int>>
const ll MOD=1e9+7;
# define MAXINT 1000*1000*1000
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin) ;
        freopen("output.txt" , "w" , stdout) ;
    #endif
    int n,i,j;
    cin>>n;
    vector<string>a(n);
    input(a);
    for(i=0;i<n;++i)
    {
        for(j=0;j<n;++j)
        {
            if(a[i][j]=='.')
            {
                a[i][j]='#';
                if(i+2>=n || j-1<0 || j+1>=n)
                {
                    cout<<"NO";
                    return 0;
                }
                if(a[i+1][j]=='.' && a[i+1][j-1]=='.' && a[i+1][j+1]=='.' && a[i+2][j]=='.')
                {
                    a[i+1][j]='#';
                    a[i+2][j]='#';
                    a[i+1][j-1]='#';
                    a[i+1][j+1]='#';
                }
                else
                {
                    cout<<"NO";
                    return 0;
                }
            }

        }
    }
    cout<<"YES";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  input(a) for(auto &it:a) cin>>it;
#define output(a) for(auto it:a) cout<<it<<" ";
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vpi vector<pair<int,int>>
const ll MOD=1e9+7;
# define MAXINT 1000*1000*1000
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin) ;
        freopen("output.txt" , "w" , stdout) ;
    #endif
    int n,i,j;
    cin>>n;
    vector<string>a(n);
    input(a);
    for(i=0;i<n;++i)
    {
        for(j=0;j<n;++j)
        {
            if(a[i][j]=='.')
            {
                a[i][j]='#';
                if(i+2>n && j-1<0 && j+1>n)
                {
                    cout<<"1NO";
                    return 0;
                }
                if(a[i+1][j]=='.' && a[i+1][j-1]=='.' && a[i+1][j+1]=='.' && a[i+2][j]=='.')
                {
                    a[i+1][j]='#';
                    a[i+2][j]='#';
                    a[i+1][j-1]='#';
                    a[i+1][j+1]='#';
                }
                else
                {
                    cout<<"NO";
                    return 0;
                }
            }

        }
    }
    cout<<"YES";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  input(a) for(auto &it:a) cin>>it;
#define output(a) for(auto it:a) cout<<it<<" ";
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vpi vector<pair<int,int>>
const ll MOD=1e9+7;
# define MAXINT 1000*1000*1000
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin) ;
        freopen("output.txt" , "w" , stdout) ;
    #endif
    int n,i,j;
    cin>>n;
    vector<string>a(n);
    input(a);
    for(i=0;i<n;++i)
    {
        for(j=0;j<n;++j)
        {
            if(a[i][j]=='.')
            {
                a[i][j]='#';
                if(i+2>n || j-1<0 || j+1>n)
                {
                    cout<<"NO";
                    return 0;
                }
                if(a[i+1][j]=='.' && a[i+1][j-1]=='.' && a[i+1][j+1]=='.' && a[i+2][j]=='.')
                {
                    a[i+1][j]='#';
                    a[i+2][j]='#';
                    a[i+1][j-1]='#';
                    a[i+1][j+1]='#';
                }
                else
                {
                    cout<<"NO";
                    return 0;
                }
            }

        }
    }
    cout<<"YES";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  input(a) for(auto &it:a) cin>>it;
#define output(a) for(auto it:a) cout<<it<<" ";
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vpi vector<pair<int,int>>
const ll MOD=1e9+7;
# define MAXINT 1000*1000*1000
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin) ;
        freopen("output.txt" , "w" , stdout) ;
    #endif
    int n,i,j;
    cin>>n;
    vector<string>a(n);
    input(a);
    for(i=0;i<n;++i)
    {
        for(j=0;j<n;++j)
        {
            if(a[i][j]=='.')
            {
                a[i][j]='#';
                if(i>n-2 && j==0 && j==n-1)
                {
                    cout<<"NO";
                    return 0;
                }
                if(a[i+1][j]=='.' && a[i+1][j-1]=='.' && a[i+1][j+1]=='.' && a[i+2][j]=='.')
                {
                    a[i+1][j]='#';
                    a[i+2][j]='#';
                    a[i+1][j-1]='#';
                    a[i+1][j+1]='#';
                }
                else
                {
                    cout<<"NO";
                    return 0;
                }
            }

        }
    }
    cout<<"YES";
    return 0;
}


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

int marks[55][55];

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> arr(n);
    for (auto &el: arr) cin >> el;

    int cnt = 0;
    for (int i = 1; i < n - 1; ++i) {
        for (int j = 1; j < n - 1; ++j) {
            unordered_map<char, int> mp;
            vector<pair<int, int>> coords
                {
                    {i, j},
                    {i, j - 1},
                    {i, j + 1},
                    {i - 1, j},
                    {i + 1, j}
                };

            for (auto el: coords) mp[arr[el.first][el.second]]++;
            if ( mp['.'] == 5 ) {

                bool taken = false;

                // check if already taken
                for (auto el: mp)
                    if ( marks[el.first][el.second] )
                        taken = true;

                if ( !taken ) {
                    cnt++;
                    for (auto el: coords) {
                        marks[el.first][el.second] = true;
                        arr[el.first][el.second] = 'F';
                    }
                }
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if ( arr[i][j] == '.' ) {
                cout << "NO" << endl;
                return 0;
            }
        }
    }

    if (cnt > 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

bool marks[55][55];

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> arr(n);
    for (auto &el: arr) cin >> el;

    int cnt = 0;
    for (int i = 1; i < n - 1; ++i) {
        for (int j = 1; j < n - 1; ++j) {
            unordered_map<char, int> mp;
            vector<pair<int, int>> coords
                {
                    {i, j},
                    {i, j - 1},
                    {i, j + 1},
                    {i - 1, j},
                    {i + 1, j}
                };

            for (auto el: coords) mp[arr[el.first][el.second]]++;
            if ( mp['.'] == 5 ) {
                bool taken = false;

                // check if already taken
                for (auto el: coords)
                    if ( marks[el.first][el.second] ) {
                        taken = true;
                        break;
                    }

                if ( !taken ) {
                    cnt++;
                    for (auto el: coords) {
                        marks[el.first][el.second] = true;
                        arr[el.first][el.second] = 'F';
                    }
                }
            }
        }
    }

    bool flag = true;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cout << arr[i][j];
            if ( arr[i][j] == '.' ) flag = false;
        }
        cout << endl;
    }

    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

int marks[55][55];

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> arr(n);
    for (auto &el: arr) cin >> el;

    int cnt = 0;
    bool flag = true;
    for (int i = 1; i < n - 1; ++i) {
        for (int j = 1; j < n - 1; ++j) {
            unordered_map<char, int> mp;
            vector<pair<int, int>> coords
                {
                    {i, j},
                    {i, j - 1},
                    {i, j + 1},
                    {i - 1, j},
                    {i + 1, j}
                };

            bool used = false;

            for (auto el: coords) mp[arr[el.first][el.second]]++;
            if ( mp['.'] == 5 ) {

                bool taken = false;

                // check if already taken
                for (auto el: mp)
                    if ( marks[el.first][el.second] )
                        taken = true;

                if ( !taken ) {
                    cnt++;
                    for (auto el: coords) {
                        marks[el.first][el.second] = true;
                        arr[el.first][el.second] = 'F';
                    }
                }
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (arr[i][j] == '.') {
                cout << "NO" << endl;
                return 0;
            }
        }
    }

    cout << "YES" << endl;
    return 0;
}


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

bool marks[55][55];

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> arr(n);
    for (auto &el: arr) cin >> el;

    int cnt = 0;
    for (int i = 1; i < n - 1; ++i) {
        for (int j = 1; j < n - 1; ++j) {
            unordered_map<char, int> mp;
            vector<pair<int, int>> coords
                {
                    {i, j},
                    {i, j - 1},
                    {i, j + 1},
                    {i - 1, j},
                    {i + 1, j}
                };

            for (auto el: coords) mp[arr[el.first][el.second]]++;
            if ( mp['.'] == 5 ) {
                bool taken = false;

                // check if already taken
                for (auto el: coords)
                    if ( marks[el.first][el.second] ) {
                        taken = true;
                        break;
                    }

                if ( !taken ) {
                    cnt++;
                    for (auto el: coords) {
                        marks[el.first][el.second] = true;
                        arr[el.first][el.second] = 'F';
                    }
                }
            }
        }
    }

    bool flag = true;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if ( arr[i][j] == '.' ) {
                cout << "NO" << endl;
                return 0;
            }
        }
    }

    cout << "YES" << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
char str[35][35];
int xx[4]={0,0,-1,1};
int yy[4]={1,-1,0,0};
bool check(int i,int j){
	int right = i+1;
	int dowm =  j+1;
	int left = i-1;
	int up = j-1;
	if(str[i][j+1]=='.'&&str[i][j-1]=='.'&&str[i-1][j]=='.'&&str[i+1][j]=='.'&&right<n&&dowm<n&&left>=0&&up>=0)
	{
		str[i][j+1]=='#';
		str[i][j-1]=='#';
		str[i+1][j]=='#';
		str[i-1][j]=='#';
		return true;
	}
	return false;
}

int main()
{
	scanf("%d",&n);
	int count =0;
	for(int i=0;i<n;i++)
	{
		scanf("%s",str[i]);
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(str[i][j]=='.')
			{
				count++;
			}
		}
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(str[i][j]=='.'&&check(i,j))
			{
				ans++;
			}
		}
	}
	if(ans*5==count)
	{
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
char str[35][35];
int xx[4]={0,0,-1,1};
int yy[4]={1,-1,0,0};
bool check(int i,int j){
	int right = i+1;
	int dowm =  j+1;
	int left = i-1;
	int up = j-1;
	if(str[i][j+1]=='.'&&str[i][j-1]=='.'&&str[i-1][j]=='.'&&str[i+1][j]=='.'&&right<n&&dowm<n&&left>=0&&up>=0)
	{
		str[i][j+1]='#';
		str[i][j-1]='#';
		str[i+1][j]='#';
		str[i-1][j]='#';

		return true;
	}
	return false;
}

int main()
{
	scanf("%d",&n);
	int count =0;
	for(int i=0;i<n;i++)
	{
		scanf("%s",str[i]);
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(str[i][j]=='.')
			{
				count++;
			}
		}
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(str[i][j]=='.'&&check(i,j))
			{

				ans++;
				//printf("第%d次变换如上\n",ans);
			}
		}
	}
	if(ans*5==count)
	{
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
char str[55][55];
int xx[4]={0,0,-1,1};
int yy[4]={1,-1,0,0};
	int ans=0;
bool check(int i,int j){
	int right = i+1;
	int dowm =  j+1;
	int left = i-1;
	int up = j-1;
	if(str[i][j+1]=='.'&&str[i][j-1]=='.'&&str[i-1][j]=='.'&&str[i+1][j]=='.'&&right<n&&dowm<n&&left>=0&&up>=0)
	{
		str[i][j+1]='#';
		str[i][j-1]='#';
		str[i+1][j]='#';
		str[i-1][j]='#';
		str[i][j]='#';

		return true;
	}
	return false;
}

int main()
{
	scanf("%d",&n);
	int count =0;
	for(int i=0;i<n;i++)
	{
		scanf("%s",str[i]);
	}

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(str[i][j]=='.'&&check(i,j))
			{
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(str[i][j]=='.')
			{
				cout<<"NO"<<endl;
				return 0;
			}
		}
	}
	cout<<"YES"<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
char str[35][35];
int xx[4]={0,0,-1,1};
int yy[4]={1,-1,0,0};
	int ans=0;
bool check(int i,int j){
	int right = i+1;
	int dowm =  j+1;
	int left = i-1;
	int up = j-1;
	if(str[i][j+1]=='.'&&str[i][j-1]=='.'&&str[i-1][j]=='.'&&str[i+1][j]=='.'&&right<n&&dowm<n&&left>=0&&up>=0)
	{
		str[i][j+1]='#';
		str[i][j-1]='#';
		str[i+1][j]='#';
		str[i-1][j]='#';
		str[i][j]='#';

		return true;
	}
	return false;
}

int main()
{
	scanf("%d",&n);
	int count =0;
	for(int i=0;i<n;i++)
	{
		scanf("%s",str[i]);
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(str[i][j]=='.')
			{
				count++;
			}
		}
	}

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(str[i][j]=='.'&&check(i,j))
			{

				ans++;

			}
		}
	}
	if(ans*5==count)
	{
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
char str[35][35];
int xx[4]={0,0,-1,1};
int yy[4]={1,-1,0,0};
	int ans=0;
bool check(int i,int j){
	int right = i+1;
	int dowm =  j+1;
	int left = i-1;
	int up = j-1;
	if(str[i][j+1]=='.'&&str[i][j-1]=='.'&&str[i-1][j]=='.'&&str[i+1][j]=='.'&&right<n&&dowm<n&&left>=0&&up>=0)
	{
		str[i][j+1]='#';
		str[i][j-1]='#';
		str[i+1][j]='#';
		str[i-1][j]='#';
		str[i][j]='#';

		return true;
	}
	return false;
}

int main()
{
	scanf("%d",&n);
	int count =0;
	for(int i=0;i<n;i++)
	{
		scanf("%s",str[i]);
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(str[i][j]=='.')
			{
				cout<<"NO"<<endl;
				return 0;
			}
		}
	}
	cout<<"YES"<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
char str[35][35];
int xx[4]={0,0,-1,1};
int yy[4]={1,-1,0,0};
	int ans=0;
bool check(int i,int j){
	int right = i+1;
	int dowm =  j+1;
	int left = i-1;
	int up = j-1;
	if(str[i][j+1]=='.'&&str[i][j-1]=='.'&&str[i-1][j]=='.'&&str[i+1][j]=='.'&&right<n&&dowm<n&&left>=0&&up>=0)
	{
		str[i][j+1]='#';
		str[i][j-1]='#';
		str[i+1][j]='#';
		str[i-1][j]='#';
		str[i][j]='#';

		return true;
	}
	return false;
}

int main()
{
	scanf("%d",&n);
	int count =0;
	for(int i=0;i<n;i++)
	{
		scanf("%s",str[i]);
	}
	int flag = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(str[i][j]=='.')
			{
				if(!check(i,j)) {
					flag=0;
				}else{
					flag=1;
				}
			}
		}
	}
	if(flag==1)
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
char str[35][35];
int xx[4]={0,0,-1,1};
int yy[4]={1,-1,0,0};
	int ans=0;
bool check(int i,int j){
	int right = i+1;
	int dowm =  j+1;
	int left = i-1;
	int up = j-1;
	if(str[i][j+1]=='.'&&str[i][j-1]=='.'&&str[i-1][j]=='.'&&str[i+1][j]=='.'&&right<n&&dowm<n&&left>=0&&up>=0)
	{
		str[i][j+1]='#';
		str[i][j-1]='#';
		str[i+1][j]='#';
		str[i-1][j]='#';
		str[i][j]='#';

		return true;
	}
	return false;
}

int main()
{
	scanf("%d",&n);
	int count =0;
	for(int i=0;i<n;i++)
	{
		scanf("%s",str[i]);
	}

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(str[i][j]=='.'&&check(i,j))
			{
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(str[i][j]=='.')
			{
				cout<<"NO"<<endl;
				return 0;
			}
		}
	}
	cout<<"YES"<<endl;
	return 0;
}


#include <iostream>
#include<string>
#include <sstream>
#include<vector>
#include<bits/stdc++.h>
#include <sys/types.h>
#include <string.h>

using namespace std;

int main()
{

int n;

char c;

bool b;

cin>>n;

int a[n][n];

for(int i=0;i<n;i++)

     for(int j=0;j<n;j++)
       a[i][j]=0;
for(int i=0;i<n;i++)
{

     for(int j=0;j<n;j++)

              {
                  b=false;

            cin>>c;
            if(c=='#'&&a[i][j]==1)
            {
                cout<<"NO";
                return 0;
            }

            if(j==0)
            {
                if((a[i][j]==0)&&(c=='.'))
                {
                          cout<<"NO";
                          return 0;

                }
            }

                if(j==n-1)
            {
                if((a[i][j]==0)&&(c=='.'))
                {
                          cout<<"NO";
                          return 0;

                }
            }

            if(c=='.'&&a[i][j]==0)
                 {
                     a[i][j]=1;
                     a[i+1][j]=1;
                     a[i+1][j+1]=1;
                    a[i+1][j-1]=1;
                    a[i+2][j]=1;
                    b=true;
                 }

                 if(c=='.'&&a[i][j]==0&&a[i][j-1]==1&&b==true)

              {
                          cout<<"NO";
                          return 0;

              }
              }

}

cout<<"YES";

}


#include <iostream>
#include<string>
#include <sstream>
#include<vector>
#include<bits/stdc++.h>
#include <sys/types.h>
#include <string.h>

using namespace std;

int main()
{

int n;

char c;

cin>>n;

int a[n][n];

for(int i=0;i<n;i++)

     for(int j=0;j<n;j++)
       a[i][j]=0;
for(int i=0;i<n;i++)
{

     for(int j=0;j<n;j++)

              {

            cin>>c;

            if((i==0&&j==0)||(i==0&&j==n-1))
            {
                if(c=='.')
                {
                       cout<<"NO";
                return 0;
                }

            }
            if(c=='#'&&a[i][j]==1)
            {
                cout<<"NO";
                return 0;
            }
            if(c=='.'&&a[i][j]==0)
                 {
                     a[i][j]=1;
                     a[i+1][j]=1;
                     a[i+1][j+1]=1;
                    a[i+1][j-1]=1;
                    a[i+2][j]=1;
                 }
              }

}

cout<<"YES";

}


#include <iostream>
#include<string>
#include <sstream>
#include<vector>
#include<bits/stdc++.h>
#include <sys/types.h>
#include <string.h>

using namespace std;

int main()
{

int n,x;

char c;

cin>>n;

int a[n][n];

for(int i=0;i<n;i++)

     for(int j=0;j<n;j++)
       a[i][j]=0;
for(int i=0;i<n;i++)
{

        x=-70;
     for(int j=0;j<n;j++)

              {

            cin>>c;
            if((i==0&&j==0)||(i==n-1&&j==n-1))
            {
                if(c=='.')
               {
                cout<<"NO";
                return 0;
               }

            }

            if(c=='#'&&a[i][j]==1)
            {
                cout<<"NO";
                return 0;
            }
            if(c=='.'&&a[i][j]==0)
                 {
                     if(i-3>=x)
                    {

                     a[i][j]=1;
                     a[i+1][j]=1;
                     a[i+1][j+1]=1;
                    a[i+1][j-1]=1;
                    a[i+2][j]=1;
                    x=i;
                    }

                    else
                        {
                cout<<"NO";
                return 0;
                      }
                 }
              }

}

cout<<"YES";

}


#include <iostream>
#include<string>
#include <sstream>
#include<vector>
#include<bits/stdc++.h>
#include <sys/types.h>
#include <string.h>

using namespace std;

int main()
{

int n,x=0;

char c;

bool b;

cin>>n;

int a[n][n];

for(int i=0;i<n;i++)

     for(int j=0;j<n;j++)
       a[i][j]=0;
for(int i=0;i<n;i++)
{

     for(int j=0;j<n;j++)

              {
                  b=false;

            cin>>c;

            if(x==0&&i>=n-2)

             {
                cout<<"NO";
                return 0;
            }

            if(c=='#'&&a[i][j]==1)
            {
                cout<<"NO";
                return 0;
            }

            if(j==0)
            {
                if((a[i][j]==0)&&(c=='.'))
                {
                          cout<<"NO";
                          return 0;

                }
            }

                if(j==n-1)
            {
                if((a[i][j]==0)&&(c=='.'))
                {
                          cout<<"NO";
                          return 0;

                }
            }

            if(c=='.'&&a[i][j]==0)
                 {
                     a[i][j]=1;
                     a[i+1][j]=1;
                     a[i+1][j+1]=1;
                    a[i+1][j-1]=1;
                    a[i+2][j]=1;
                    b=true;
                    x++;
                 }

                 if(c=='.'&&a[i][j]==0&&a[i][j-1]==1&&b==true)

              {
                          cout<<"NO";
                          return 0;

              }
              }

}

cout<<"YES";

}


#include <iostream>
#include<string>
#include <sstream>
#include<vector>
#include<bits/stdc++.h>
#include <sys/types.h>
#include <string.h>

using namespace std;

int main()
{

int n,b=1;

char c;

cin>>n;

int a[n][n];

for(int i=0;i<n;i++)

     for(int j=0;j<n;j++)
       a[i][j]=0;
for(int i=0;i<n;i++)
{

     for(int j=0;j<n;j++)

              {

            cin>>c;

            if(a[i][j]==0)
            {
            if((c=='#'&&a[i][j]==1)||(c=='.'&&a[i+1][j]==1))
            {
             b=0;
            }
            if(c=='.'&&a[i][j]==0)
                 {
                     a[i][j]=1;
                     a[i+1][j]=1;
                     a[i+1][j+1]=1;
                    a[i+1][j-1]=1;
                    a[i+2][j]=1;
                 }
              }

}
if(b)
cout<<"YES";
else
    cout<<"NO";
}


#include <iostream>
#include<string>
#include <sstream>
#include<vector>
#include<bits/stdc++.h>
#include <sys/types.h>
#include <string.h>

using namespace std;

int main()
{

int n,b=1;

char c;

cin>>n;

int a[n][n];

for(int i=0;i<n;i++)

     for(int j=0;j<n;j++)
       a[i][j]=0;
for(int i=0;i<n;i++)
{

     for(int j=0;j<n;j++)

              {

            cin>>c;
            if(c=='#'&&a[i][j]==1)
            {
             b=0;
            }
            if(c=='.'&&a[i][j]==0)
                 {
                     a[i][j]=1;
                     a[i+1][j]=1;
                     a[i+1][j+1]=1;
                    a[i+1][j-1]=1;
                    a[i+2][j]=1;
                 }
              }

}
if(b)
cout<<"YES";
else
    cout<<"NO";
}


#include <iostream>
#include<string>
#include <sstream>
#include<vector>
#include<bits/stdc++.h>
#include <sys/types.h>
#include <string.h>

using namespace std;

int main()
{

int n,x,y,m=0;
cin>>n;

for(int i=0;i<n;i++)
{
cin>>x>>y;

if((x+y)>m)
{
    m=x+y;

}

}

cout<<m;

}


#include <iostream>
#include<string>
#include <sstream>
#include<vector>
#include<bits/stdc++.h>
#include <sys/types.h>
#include <string.h>

using namespace std;

int main()
{

int n,b=1;

char c;

cin>>n;

int a[n][n];

for(int i=0;i<n;i++)

     for(int j=0;j<n;j++)
       a[i][j]=0;
for(int i=0;i<n;i++)
{

     for(int j=0;j<n;j++)

              {

            cin>>c;
            if((c=='#'&&a[i][j]==1)||(c=='.'&&a[i+1][j]==1))
            {
             b=0;
            }
            if(c=='.'&&a[i][j]==0)
                 {
                     a[i][j]=1;
                     a[i+1][j]=1;
                     a[i+1][j+1]=1;
                    a[i+1][j-1]=1;
                    a[i+2][j]=1;
                 }
              }

}
if(b)
cout<<"YES";
else
    cout<<"NO";
}


#include <iostream>
#include<string>
#include <sstream>
#include<vector>
#include<bits/stdc++.h>
#include <sys/types.h>
#include <string.h>

using namespace std;

int main()
{

int n;

char c;

cin>>n;

int a[n][n];

for(int i=0;i<n;i++)

     for(int j=0;j<n;j++)
       a[i][j]=0;
for(int i=0;i<n;i++)
{

     for(int j=0;j<n;j++)

              {

            cin>>c;
            if(c=='#'&&a[i][j]==1)
            {
                cout<<"NO";
                return 0;
            }
            if(c=='.'&&a[i][j]==0)
                 {
                     a[i][j]=1;
                     a[i+1][j]=1;
                     a[i+1][j+1]=1;
                    a[i+1][j-1]=1;
                    a[i+2][j]=1;
                 }
              }

}

cout<<"YES";

}


#include <iostream>
#include<string>
#include <sstream>
#include<vector>
#include<bits/stdc++.h>
#include <sys/types.h>
#include <string.h>

using namespace std;

int main()
{

int n;

char c;

cin>>n;

int a[n][n];

for(int i=0;i<n;i++)

     for(int j=0;j<n;j++)
       a[i][j]=0;
for(int i=0;i<n;i++)
{

     for(int j=0;j<n;j++)

              {

            cin>>c;

            if((a[i][0]==0)||(a[i][n-1]==0))
            {
                if(c=='.')
                {
                       cout<<"NO";
                return 0;
                }

            }
            if(c=='#'&&a[i][j]==1)
            {
                cout<<"NO";
                return 0;
            }
            if(c=='.'&&a[i][j]==0)
                 {
                     a[i][j]=1;
                     a[i+1][j]=1;
                     a[i+1][j+1]=1;
                    a[i+1][j-1]=1;
                    a[i+2][j]=1;
                 }
              }

}

cout<<"YES";

}


#include <iostream>
#include<string>
#include <sstream>
#include<vector>
#include<bits/stdc++.h>
#include <sys/types.h>
#include <string.h>

using namespace std;

int main()
{

int n,b=1;

char c;

cin>>n;

int a[n][n];

for(int i=0;i<n;i++)

     for(int j=0;j<n;j++)
       a[i][j]=0;
for(int i=0;i<n;i++)
{

     for(int j=0;j<n;j++)

              {

            cin>>c;

            if(a[i][j]==0)
            {
            if((c=='#'&&a[i][j]==1)||(c=='.'&&a[i+1][j]==1))
            {
             b=0;
            }
            if(c=='.'&&a[i][j]==0)
                 {
                     a[i][j]=1;
                     a[i+1][j]=1;
                     a[i+1][j+1]=1;
                    a[i+1][j-1]=1;
                    a[i+2][j]=1;
                 }
              }

}
}
if(b)
cout<<"YES";
else
    cout<<"NO";
}


#include <iostream>
#include<string>
#include <sstream>
#include<vector>
#include<bits/stdc++.h>
#include <sys/types.h>
#include <string.h>

using namespace std;

int main()
{

int n,b=1;

char c;

cin>>n;

int a[n][n];

for(int i=0;i<n;i++)

     for(int j=0;j<n;j++)
       a[i][j]=0;
for(int i=0;i<n;i++)
{

     for(int j=0;j<n;j++)

              {

            cin>>c;
            if((c=='#'&&a[i][j]==1)||(a[0][0])||a[0][n-1])
            {
             b=0;
            }
            if(c=='.'&&a[i][j]==0)
                 {
                     a[i][j]=1;
                     a[i+1][j]=1;
                     a[i+1][j+1]=1;
                    a[i+1][j-1]=1;
                    a[i+2][j]=1;
                 }
              }

}
if(b)
cout<<"YES";
else
    cout<<"NO";
}


#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
char arr[n][n];
double counter1=0,counter2=0;
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
    cin>>arr[i][j];
    if(arr[i][j]=='.')counter1++;
 }
}
counter1/=5.0;
for(int i=1;i<n-1;i++){
    for(int j=1;j<n-1;j++){
if(arr[i-1][j]=='.'&&arr[i][j+1]=='.'&&arr[i][j]=='.'&&arr[i][j-1]=='.'&&arr[i+1][j]=='.')counter2++;
}
}
if(counter1==counter2)cout<<"YES";
else cout<<"NO";
    return 0 ;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
char arr[n][n];
double counter1=0,counter2=0;
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
    cin>>arr[i][j];
    if(arr[i][j]=='.')counter1++;
 }
}
counter1/=5.0;
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
if(arr[i-1][j]=='.'&&arr[i][j+1]=='.'&&arr[i][j]=='.'&&arr[i][j-1]=='.'&&arr[i+1][j]=='.')counter2++;
}
}
if(counter1==counter2&&counter1!=0)cout<<"YES";
else cout<<"NO";
    return 0 ;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
char arr[n][n];
double counter1=0,counter2=0;
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
    cin>>arr[i][j];
    if(arr[i][j]=='.')counter1++;
 }
}
counter1/=5.0;
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
if(arr[i-1][j]=='.'&&arr[i][j+1]=='.'&&arr[i][j]=='.'&&arr[i][j-1]=='.'&&arr[i+1][j]=='.')counter2++;
}
}
if(counter1==counter2)cout<<"YES";
else cout<<"NO";
    return 0 ;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
char arr[n][n];
double counter1=0,counter2=0;
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
    cin>>arr[i][j];
    if(arr[i][j]=='.')counter1++;
 }
}
counter1/=5.0;
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
if(arr[i-1][j]=='.'&&arr[i][j+1]=='.'&&arr[i][j]=='.'&&arr[i][j-1]=='.'&&arr[i+1][j]=='.')counter2++;
}
}
if(counter1==0){
    cout<<"YES";
    return 0;
}
if(counter1==counter2)cout<<"YES";
else cout<<"NO";
    return 0 ;
}


#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char str[n*n];
    int count=0;
    for(int i=0; i<(n*n); i++)
    {
        cin>>str[i];
        if(str[i]=='.')
            count++;
    }
    int tru=0;
    if(count%5==0)
    {
        if(count==0)
        {
            cout<<"YES"<<endl;
            return 0;
        }
        else
        {
            for(int i=0; i<(n*n); i++)
            {
                if(str[i]=='.')
                {
                    if(str[i+(n-1)]=='.' && str[i+n]=='.' && str[i+n+1]=='.' && str[i+n+n]=='.')
                    {
                        tru=1;
                        str[i]='#';
                        str[i+(n-1)]='#';
                        str[i+n]='#';
                        str[i+n+1]='#';
                        str[i+n+n]='#';
                    }
                    else
                    {
                        tru=0;
                        break;
                    }
                }
            }
            if(tru==0)
            {
                cout<<"NO"<<endl;
                return 0;
            }
            else
            {
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }
    else
        cout<<"NO"<<endl;
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char str[n*n];
    int count=0;
    for(int i=0; i<(n*n); i++)
    {
        cin>>str[i];
        if(str[i]=='.')
            count++;
    }
    int tru=0;
    if(count%5==0)
    {
        if(count==0)
        {
            cout<<"YES"<<endl;
            return 0;
        }
        else
        {
            for(int i=0; i<(n*n); i++)
            {
                if(str[i]=='.')
                {
                    if((i+1)%n==0)
                    {
                        cout<<"NO"<<endl;
                        return 0;
                    }
                    else
                    {
                        if(str[i+(n-1)]=='.' && str[i+n]=='.' && str[i+n+1]=='.' && str[i+n+n]=='.')
                        {
                            tru=1;
                            str[i]='#';
                            str[i+(n-1)]='#';
                            str[i+n]='#';
                            str[i+n+1]='#';
                            str[i+n+n]='#';
                        }
                        else
                        {
                            tru=0;
                            break;
                        }
                    }
                }
            }
            if(tru==0)
            {
                cout<<"NO"<<endl;
                return 0;
            }
            else
            {
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }
    else
        cout<<"NO"<<endl;
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char str[n*n];
    int count=0;
    for(int i=0; i<(n*n); i++)
    {
        cin>>str[i];
        if(str[i]=='.')
            count++;
    }
    int tru=0;
    if(count%5==0)
    {
        if(count==0)
        {
            cout<<"YES"<<endl;
            return 0;
        }
        else
        {
            for(int i=0; i<(n*n); i++)
            {
                if(str[i]=='.')
                {
                    if((i+1)%n==0 || i%n==0)
                    {
                        cout<<"NO"<<endl;
                        return 0;
                    }
                    else
                    {
                        if(str[i+(n-1)]=='.' && str[i+n]=='.' && str[i+n+1]=='.' && str[i+n+n]=='.')
                        {
                            tru=1;
                            str[i]='#';
                            str[i+(n-1)]='#';
                            str[i+n]='#';
                            str[i+n+1]='#';
                            str[i+n+n]='#';
                        }
                        else
                        {
                            tru=0;
                            break;
                        }
                    }
                }
            }
            if(tru==0)
            {
                cout<<"NO"<<endl;
                return 0;
            }
            else
            {
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }
    else
        cout<<"NO"<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;
int n;
vi v;
int num[3]={-9999999,-99999999,-99999999};
int cntt[3];
int numn=0;
int cnt[3],tmp,o[3];
map<int,int> m;
map<int,int>::iterator it;
void read(int &x)
{
    x=0; int f=1; char c=getchar();
    while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
    while(isdigit(c)) { x=x*10+c-'0'; c=getchar(); }
    x*=f;
}
int main(){
	scanf("%d",&n);
	rep(i,0,n)
	{
		//scanf("%d",&tmp);
		read(tmp);
		if((num[0]==tmp)) cntt[0]++;
		else if(num[1]==tmp) cntt[1]++;
		else if(num[2]==tmp) cntt[2]++;
		else {
			num[numn]=tmp;
			cntt[numn++]=1;
		}
	//	m[tmp]++;
	}

	rep(i,0,numn) m[num[i]]=cntt[i];

	int cc=m.size();
	if(cc==1||cc==2&&abs(num[0]-num[1])==1)
	{
	printf("%d\n",n);

		int cnt1=0;
		for(it=m.begin();it!=m.end();it++)
		{
			rep(j,0,it->second) printf("%d%s",it->first,(cnt1++)==n-1?"\n":" ");
		}

	return 0;
	}
	else if(cc==2)
	{
		if(num[0]>num[1])swap(num[0],num[1]);
		int aa=m[ num[0] ];
		int bb=m[ num[1] ];
		int tt=min(aa,bb);

		rep(i,0,aa-tt) v.pb(num[0]);
		rep(i,0,2*tt) v.pb(num[0]+1);
		rep(i,0,bb-tt) v.pb(num[1]);
		printf("%d\n",n-(2*tt));
		rep(i,0,v.size()) printf("%d%c",v[i],i==v.size()-1?'\n':' ');
		return 0;
	}

		int k=0;
		for(it=m.begin();it!=m.end();it++)	cnt[k++]=it->second;
		int t=min(cnt[0],cnt[2]);
//		de(cnt[0]);de(cnt[1]);de(cnt[2]);
		if(t<cnt[1]/2)//中间到两边
		{
			printf("%d\n",n-cnt[1]/2*2);
			o[0]=cnt[0]+cnt[1]/2;
			o[1]=(cnt[1]%2==0?0:1);
			o[2]=cnt[2]+cnt[1]/2;
		}
		else
		{
			printf("%d\n",n-2*t);
			o[0]=cnt[0]-t;
			o[1]=cnt[1]+2*t;
			o[2]=cnt[2]-t;
			//de(o[0]);de(o[1]);de(o[2]);
		}
		it=m.begin();
		int out=it->first;
		rep(i,0,o[0]) printf("%d%c",out,i==o[0]-1&&o[0]==n?'\n':' ');
		it++;
		out=it->first;
		rep(i,0,o[1]) printf("%d%c",out,(i==o[1]-1&&o[0]+o[1]==n)?'\n':' ');
		it++;
		out=it->first;
		rep(i,0,o[2]) printf("%d%c",out,i==o[2]-1?'\n':' ');

    return 0;
}
/*
9
1 1 2 2 2 2 2 2 3

2
0 2
*/


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;
int n;
int num[3]={-9999999,-99999999,-99999999};
int cntt[3];
int numn=0;
int cnt[3],tmp,o[3];
map<int,int> m;
map<int,int>::iterator it;
void read(int &x)
{
    x=0; int f=1; char c=getchar();
    while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
    while(isdigit(c)) { x=x*10+c-'0'; c=getchar(); }
    x*=f;
}
int main(){
	scanf("%d",&n);
	rep(i,0,n)
	{
		//scanf("%d",&tmp);
		read(tmp);
		if((num[0]==tmp)) cntt[0]++;
		else if(num[1]==tmp) cntt[1]++;
		else if(num[2]==tmp) cntt[2]++;
		else {
			num[numn]=tmp;
			cntt[numn++]=1;
		}
	//	m[tmp]++;
	}

	rep(i,0,numn) m[num[i]]=cntt[i];

	int cc=m.size();
	if(cc<=2)
	{
	printf("%d\n",n);

		int cnt1=0;
		for(it=m.begin();it!=m.end();it++)
		{
			rep(j,0,it->second) printf("%d%s",it->first,(cnt1++)==n-1?"\n":" ");
		}

	return 0;
	}

		int k=0;
		for(it=m.begin();it!=m.end();it++)	cnt[k++]=it->second;
		int t=min(cnt[0],cnt[2]);
//		de(cnt[0]);de(cnt[1]);de(cnt[2]);
		if(t<cnt[1]/2)
		{
		printf("%d\n",n-cnt[1]/2*2);
			o[0]=cnt[0]+cnt[1]/2;
			o[1]=(cnt[1]%2==0?0:1);
			o[2]=cnt[2]+cnt[1]/2;
		}
		else
		{
			printf("%d\n",n-2*t);
			o[0]=cnt[0]-t;
			o[1]=cnt[1]+2*t;
			o[2]=cnt[2]-t;
			//de(o[0]);de(o[1]);de(o[2]);
		}
		it=m.begin();
		rep(i,0,o[0]) printf("%d%c",it->first,i==cnt[0]-1&&cnt[0]==n?'\n':' ');
		it++;
		rep(i,0,o[1]) printf("%d%c",it->first,(i==cnt[1]-1&&cnt[0]+cnt[1]==n)?'\n':' ');
		it++;
		rep(i,0,o[2]) printf("%d%c",it->first,i=cnt[2]-1?'\n':' ');
    return 0;
}


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

const int N = (int)1e5+5;
map<int, int> cnt, cnt2;
vector<int> angka;
int n, nn = 0, a[N];

int main() {
	angka.clear();
	cnt.clear();
	cnt2.clear();

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (cnt[a[i]] == 0) {
			nn++;
			angka.push_back(a[i]);
		}
		cnt[a[i]]++;
	}

	sort(angka.begin(), angka.end());

	if (nn == 1) {
		printf("%d\n", n);
		for (int i = 0; i < n; i++) {
			if (i > 0) printf(" ");
			printf("%d", a[i]);
		} puts("");
	}
	else if (nn == 2) {
		if (angka[1]-angka[0] == 1) {
			printf("%d\n", n);
			for (int i = 0; i < n; i++) {
				if (i > 0) printf(" ");
				printf("%d", a[i]);
			} puts("");
		}
		else if (angka[1]-angka[0] == 2) {
			angka.push_back(angka[0]+1);
			sort(angka.begin(), angka.end());

			if (cnt[angka[0]] < cnt[angka[2]]) {
				cnt2[angka[2]] = cnt[angka[2]] - cnt[angka[0]];
				cnt2[angka[0]] = 0;
				cnt2[angka[1]] = cnt[angka[0]]*2;
			}
			else {
				cnt2[angka[0]] = cnt[angka[0]] - cnt[angka[2]];
				cnt2[angka[2]] = 0;
				cnt2[angka[1]] = cnt[angka[2]]*2;
			}

			int ans = min(cnt[angka[0]], cnt2[angka[0]]) + min(cnt[angka[1]], cnt2[angka[1]]) + min(cnt[angka[2]], cnt2[angka[2]]);
			printf("%d\n", ans);
			bool first = 0;
			int size = cnt2[angka[0]];
			for (int i = 0; i < size; i++) {
				if (!first) first = 1;
				else printf(" ");
				printf("%d", angka[0]);
			}
			size = cnt2[angka[1]];
			for (int i = 0; i < size; i++) {
				if (!first) first = 1;
				else printf(" ");
				printf("%d", angka[1]);
			}
			size = cnt2[angka[2]];
			for (int i = 0; i < size; i++) {
				if (!first) first = 1;
				else printf(" ");
				printf("%d", angka[2]);
			}
			puts("");
		}
		else assert(0);
	}
	else if (nn == 3) {
		if (min(cnt[angka[0]], cnt[angka[2]]) > cnt[angka[1]]/2) {
			if (cnt[angka[0]] < cnt[angka[2]]) {
				cnt2[angka[2]] = cnt[angka[2]] - cnt[angka[0]];
				cnt2[angka[0]] = 0;
				cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[0]]*2;
			}
			else {
				cnt2[angka[0]] = cnt[angka[0]] - cnt[angka[2]];
				cnt2[angka[2]] = 0;
				cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[2]]*2;
			}
		}
		else {
			cnt2[angka[0]] = cnt[angka[0]] + cnt[angka[1]]/2;
			cnt2[angka[2]] = cnt[angka[2]] + cnt[angka[1]]/2;
			cnt2[angka[1]] = cnt[angka[1]]%2;
		}

		int ans = min(cnt[angka[0]], cnt2[angka[0]]) + min(cnt[angka[1]], cnt2[angka[1]]) + min(cnt[angka[2]], cnt2[angka[2]]);
		printf("%d\n", ans);
		bool first = 0;
		int size = cnt2[angka[0]];
		for (int i = 0; i < size; i++) {
			if (!first) first = 1;
			else printf(" ");
			printf("%d", angka[0]);
		}
		size = cnt2[angka[1]];
		for (int i = 0; i < size; i++) {
			if (!first) first = 1;
			else printf(" ");
			printf("%d", angka[1]);
		}
		size = cnt2[angka[2]];
		for (int i = 0; i < size; i++) {
			if (!first) first = 1;
			else printf(" ");
			printf("%d", angka[2]);
		}
		puts("");
	}
	else assert(0);

	return 0;
}


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

const int N = (int)1e5+5;
map<int, int> cnt, cnt2;
vector<int> angka;
int n, nn = 0, a[N];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (cnt[a[i]] == 0) {
			nn++;
			angka.push_back(a[i]);
		}
		cnt[a[i]]++;
	}

	sort(angka.begin(), angka.end());

	if (nn == 1) {
		printf("%d\n", n);
		for (int i = 0; i < n; i++) {
			if (i > 0) printf(" ");
			printf("%d", a[i]);
		} puts("");
	}
	else if (nn == 2) {
		if (angka[1]-angka[0] == 1) {
			printf("%d\n", n);
			for (int i = 0; i < n; i++) {
				if (i > 0) printf(" ");
				printf("%d", a[i]);
			} puts("");
		}
		else if (angka[1]-angka[0] == 2) {
			angka.push_back(angka[0]+1);
			sort(angka.begin(), angka.end());

			if (cnt[angka[0]] < cnt[angka[2]]) {
				cnt2[angka[2]] = cnt[angka[2]] - cnt[angka[0]];
				cnt2[angka[0]] = 0;
				cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[0]]*2;
			}
			else {
				cnt2[angka[0]] = cnt[angka[0]] - cnt[angka[2]];
				cnt2[angka[2]] = 0;
				cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[2]]*2;
			}

			int ans = min(cnt[angka[0]], cnt2[angka[0]]) + min(cnt[angka[1]], cnt2[angka[1]]) + min(cnt[angka[2]], cnt2[angka[2]]);
			printf("%d\n", ans);
			bool first = 0;
			int size = cnt2[angka[0]];
			for (int i = 0; i < size; i++) {
				if (!first) first = 1;
				else printf(" ");
				printf("%d", angka[0]);
			}
			size = cnt2[angka[1]];
			for (int i = 0; i < size; i++) {
				if (!first) first = 1;
				else printf(" ");
				printf("%d", angka[1]);
			}
			size = cnt2[angka[2]];
			for (int i = 0; i < size; i++) {
				if (!first) first = 1;
				else printf(" ");
				printf("%d", angka[2]);
			}
			puts("");
		}
	}
	else {
		if (cnt[angka[0]] < cnt[angka[2]]) {
			cnt2[angka[2]] = cnt[angka[2]] - cnt[angka[0]];
			cnt2[angka[0]] = 0;
			cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[0]]*2;
		}
		else {
			cnt2[angka[0]] = cnt[angka[0]] - cnt[angka[2]];
			cnt2[angka[2]] = 0;
			cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[2]]*2;
		}

		int ans = min(cnt[angka[0]], cnt2[angka[0]]) + min(cnt[angka[1]], cnt2[angka[1]]) + min(cnt[angka[2]], cnt2[angka[2]]);
		printf("%d\n", ans);
		bool first = 0;
		int size = cnt2[angka[0]];
		for (int i = 0; i < size; i++) {
			if (!first) first = 1;
			else printf(" ");
			printf("%d", angka[0]);
		}
		size = cnt2[angka[1]];
		for (int i = 0; i < size; i++) {
			if (!first) first = 1;
			else printf(" ");
			printf("%d", angka[1]);
		}
		size = cnt2[angka[2]];
		for (int i = 0; i < size; i++) {
			if (!first) first = 1;
			else printf(" ");
			printf("%d", angka[2]);
		}
		puts("");
	}

	return 0;
}


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

const int N = (int)1e5+5;
map<int, int> cnt, cnt2;
vector<int> angka;
int n, nn = 0, a[N];

int main() {

	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (cnt[a[i]] == 0) {
			nn++;
			angka.push_back(a[i]);
		}
		cnt[a[i]]++;
	}

	if (nn == 1 || nn == 2) {
		printf("%d\n", n);
		for (int i = 0; i < n; i++) {
			if (i > 0) printf(" ");
			printf("%d", a[i]);
		} puts("");
	}
	else {
		int ubah, ans;
		sort(angka.begin(), angka.end());
		if (cnt[angka[0]] < cnt[angka[2]]) {
//			ubah = cnt[angka[0]];
			cnt2[angka[2]] = cnt[angka[2]] - cnt[angka[0]];
			cnt2[angka[0]] = 0;
			cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[0]]*2;
		}
		else {
//			ubah = cnt[angka[2]];
			cnt2[angka[0]] = cnt[angka[0]] - cnt[angka[2]];
			cnt2[angka[2]] = 0;
			cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[2]]*2;
		}

		ans = min(cnt[angka[0]], cnt2[angka[0]]) + min(cnt[angka[1]], cnt2[angka[1]]) + min(cnt[angka[2]], cnt2[angka[2]]);
		printf("%d\n", ans);
		bool first = 0;
		int size = cnt2[angka[0]];
		for (int i = 0; i < size; i++) {
			if (!first) first = 1;
			else printf(" ");
			printf("%d", angka[0]);
		}
		size = cnt2[angka[1]];
		for (int i = 0; i < size; i++) {
			if (!first) first = 1;
			else printf(" ");
			printf("%d", angka[1]);
		}
		size = cnt2[angka[2]];
		for (int i = 0; i < size; i++) {
			if (!first) first = 1;
			else printf(" ");
			printf("%d", angka[2]);
		}
		puts("");
	}

	return 0;
}


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

const int N = (int)1e5+5;
map<int, int> cnt, cnt2;
vector<int> angka;
int n, nn = 0, a[N];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (cnt[a[i]] == 0) {
			nn++;
			angka.push_back(a[i]);
		}
		cnt[a[i]]++;
	}

	sort(angka.begin(), angka.end());

	if (nn == 1) {
		printf("%d\n", n);
		for (int i = 0; i < n; i++) {
			if (i > 0) printf(" ");
			printf("%d", a[i]);
		} puts("");
	}
	else if (nn == 2) {
		if (angka[1]-angka[0] == 1) {
			printf("%d\n", n);
			for (int i = 0; i < n; i++) {
				if (i > 0) printf(" ");
				printf("%d", a[i]);
			} puts("");
		}
		else if (angka[1]-angka[0] == 2) {
			angka.push_back(angka[0]+1);
			sort(angka.begin(), angka.end());

			if (cnt[angka[0]] < cnt[angka[2]]) {
				cnt2[angka[2]] = cnt[angka[2]] - cnt[angka[0]];
				cnt2[angka[0]] = 0;
				cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[0]]*2;
			}
			else {
				cnt2[angka[0]] = cnt[angka[0]] - cnt[angka[2]];
				cnt2[angka[2]] = 0;
				cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[2]]*2;
			}

			int ans = min(cnt[angka[0]], cnt2[angka[0]]) + min(cnt[angka[1]], cnt2[angka[1]]) + min(cnt[angka[2]], cnt2[angka[2]]);
			printf("%d\n", ans);
			bool first = 0;
			int size = cnt2[angka[0]];
			for (int i = 0; i < size; i++) {
				if (!first) first = 1;
				else printf(" ");
				printf("%d", angka[0]);
			}
			size = cnt2[angka[1]];
			for (int i = 0; i < size; i++) {
				if (!first) first = 1;
				else printf(" ");
				printf("%d", angka[1]);
			}
			size = cnt2[angka[2]];
			for (int i = 0; i < size; i++) {
				if (!first) first = 1;
				else printf(" ");
				printf("%d", angka[2]);
			}
			puts("");
		}
	}
	else {
		if (cnt[angka[0]] + cnt[angka[2]] > cnt[angka[1]]) {
			if (cnt[angka[0]] < cnt[angka[2]]) {
				cnt2[angka[2]] = cnt[angka[2]] - cnt[angka[0]];
				cnt2[angka[0]] = 0;
				cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[0]]*2;
			}
			else {
				cnt2[angka[0]] = cnt[angka[0]] - cnt[angka[2]];
				cnt2[angka[2]] = 0;
				cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[2]]*2;
			}
		}
		else {
			cnt2[angka[0]] = cnt[angka[0]] + cnt[angka[1]]/2;
			cnt2[angka[2]] = cnt[angka[2]] + cnt[angka[1]]/2;
			cnt2[angka[1]] = cnt[angka[1]]%2;
		}

		int ans = min(cnt[angka[0]], cnt2[angka[0]]) + min(cnt[angka[1]], cnt2[angka[1]]) + min(cnt[angka[2]], cnt2[angka[2]]);
		printf("%d\n", ans);
		bool first = 0;
		int size = cnt2[angka[0]];
		for (int i = 0; i < size; i++) {
			if (!first) first = 1;
			else printf(" ");
			printf("%d", angka[0]);
		}
		size = cnt2[angka[1]];
		for (int i = 0; i < size; i++) {
			if (!first) first = 1;
			else printf(" ");
			printf("%d", angka[1]);
		}
		size = cnt2[angka[2]];
		for (int i = 0; i < size; i++) {
			if (!first) first = 1;
			else printf(" ");
			printf("%d", angka[2]);
		}
		puts("");
	}

	return 0;
}


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

const int N = (int)1e5+5;
map<int, int> cnt, cnt2;
vector<int> angka;
int n, nn = 0, a[N];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (cnt[a[i]] == 0) {
			nn++;
			angka.push_back(a[i]);
		}
		cnt[a[i]]++;
	}

	sort(angka.begin(), angka.end());

	if (nn == 1) {
		printf("%d\n", n);
		for (int i = 0; i < n; i++) {
			if (i > 0) printf(" ");
			printf("%d", a[i]);
		} puts("");
	}
	else if (nn == 2) {
		if (angka[1]-angka[0] == 1) {
			printf("%d\n", n);
			for (int i = 0; i < n; i++) {
				if (i > 0) printf(" ");
				printf("%d", a[i]);
			} puts("");
		}
		else if (angka[1]-angka[0] == 2) {
			angka.push_back(angka[0]+1);
			sort(angka.begin(), angka.end());

			if (cnt[angka[0]] < cnt[angka[2]]) {
				cnt2[angka[2]] = cnt[angka[2]] - cnt[angka[0]];
				cnt2[angka[0]] = 0;
				cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[0]]*2;
			}
			else {
				cnt2[angka[0]] = cnt[angka[0]] - cnt[angka[2]];
				cnt2[angka[2]] = 0;
				cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[2]]*2;
			}

			int ans = min(cnt[angka[0]], cnt2[angka[0]]) + min(cnt[angka[1]], cnt2[angka[1]]) + min(cnt[angka[2]], cnt2[angka[2]]);
			printf("%d\n", ans);
			bool first = 0;
			int size = cnt2[angka[0]];
			for (int i = 0; i < size; i++) {
				if (!first) first = 1;
				else printf(" ");
				printf("%d", angka[0]);
			}
			size = cnt2[angka[1]];
			for (int i = 0; i < size; i++) {
				if (!first) first = 1;
				else printf(" ");
				printf("%d", angka[1]);
			}
			size = cnt2[angka[2]];
			for (int i = 0; i < size; i++) {
				if (!first) first = 1;
				else printf(" ");
				printf("%d", angka[2]);
			}
			puts("");
		}
		else assert(0);
	}
	else if (nn == 3) {
		if (cnt[angka[0]] + cnt[angka[2]] > cnt[angka[1]]) {
			if (cnt[angka[0]] < cnt[angka[2]]) {
				cnt2[angka[2]] = cnt[angka[2]] - cnt[angka[0]];
				cnt2[angka[0]] = 0;
				cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[0]]*2;
			}
			else {
				cnt2[angka[0]] = cnt[angka[0]] - cnt[angka[2]];
				cnt2[angka[2]] = 0;
				cnt2[angka[1]] = cnt[angka[1]] + cnt[angka[2]]*2;
			}
		}
		else {
			cnt2[angka[0]] = cnt[angka[0]] + cnt[angka[1]]/2;
			cnt2[angka[2]] = cnt[angka[2]] + cnt[angka[1]]/2;
			cnt2[angka[1]] = cnt[angka[1]]%2;
		}

		int ans = min(cnt[angka[0]], cnt2[angka[0]]) + min(cnt[angka[1]], cnt2[angka[1]]) + min(cnt[angka[2]], cnt2[angka[2]]);
		printf("%d\n", ans);
		bool first = 0;
		int size = cnt2[angka[0]];
		for (int i = 0; i < size; i++) {
			if (!first) first = 1;
			else printf(" ");
			printf("%d", angka[0]);
		}
		size = cnt2[angka[1]];
		for (int i = 0; i < size; i++) {
			if (!first) first = 1;
			else printf(" ");
			printf("%d", angka[1]);
		}
		size = cnt2[angka[2]];
		for (int i = 0; i < size; i++) {
			if (!first) first = 1;
			else printf(" ");
			printf("%d", angka[2]);
		}
		puts("");
	}
	else assert(0);

	return 0;
}


#include <vector>
#include <algorithm>
#include <fstream>
#include<string>
#include <iostream>
using namespace std;
#include <map>
# include <set>

int main() {
	int n;
	vector<int> x(1000000, 0), y(1000000, 0);
	int a = 1000000, b = a, c = a, na = 0, nb = 0, nc = 0;
	cin >> n;
	int q;
	for (int i = 0; i < n; i++) {
		cin >> q;
		if (a == 1000000) { a = q; na = 0; }
		else
		{
			if (b == 1000000 && a != q) { b = q; nb = 0; }
			else
			{
				if (c == 1000000 && b != q && a != q) { c = q; nc = 0; }
			}
		}
		if (q == a) {
			na++;// cout << "kek" <<na<< endl;
		}
		if (q == b) {
			nb++; //cout << "keek" <<nb<< endl;
		}

		if (q == c) {
			nc++; //cout << "kekk" <<nc<< endl;
		}
	}
	//cout << na << ' ' << nb << ' ' << nc;
	int l;
	if (b > a) {
		l = a;
		a = b;
		b = l;
		l = na;
		na = nb;
		nb = l;

	}

	if (c > a) {
		l = a;
		a = c;
		c = l;
		l = na;
		na = nc;
		nc = l;

	}

	if (c > b) {
		l = b;
		b = c;
		c = l;
		l = nb;
		nb = nc;
		nc = l;

	}
	if (b != a + 1) {
		l = b;
		b = c;
		c = l;
		l = nb;
		nb = nc;
		nc = l;
	}
	if (a != 1000000) {
		//cout << a << ' ' << b << ' ' << c;
		//cout << na << ' ' << nb << ' ' << nc;
		if (na + nc + nb % 2 < nb + abs(na - nc)) { cout << nb % 2 + na + nc << endl; for (int i = 0; i < na + nb / 2; i++) cout << a << ' '; for (int i = 0; i < nc + nb / 2; i++) cout << c << ' '; for (int i = 0; i < nb % 2; i++) cout << b; }
		else
		{
			cout << nb + abs(na - nc) << endl;
			if (na > nc)
			{
				for (int i = 0; i < na - nc; i++) cout << a << ' ';
			}
			else
			{
				for (int i = 0; i < nc - na; i++) cout << c << ' ';
			}
			for (int i = 0; i < n - abs(na - nc); i++) cout << b << ' ';

		}
	}
	if (a == 1000000) {
		if (b == 100000) { cout << n << endl; for (int i = 0; i < n; i++) cout << c << ' '; }
		else
		{
			cout << n << endl;
			for (int i = 0; i < nb; i++)cout << b << ' ';
			for (int i = 0; i < nc; i++)cout << c << ' ';
		}
	}
	cin >> a;
	return 0;
}


#include <vector>
#include <algorithm>
#include <fstream>
#include<string>
#include <iostream>
using namespace std;
#include <map>
# include <set>

int main(){
int n;
vector<int> x(1000000, 0), y(1000000, 0);
int a = 1000000, b = a, c = a, na = 0, nb = 0, nc = 0;
cin >> n;
int q;
for (int i = 0; i < n; i++) {
	cin >> q;
	if (a == 1000000) { a = q; na = 0; }
	else
	{
		if (b == 1000000 && a!=q) { b = q; nb = 0;  }
		else
		{
			if (c == 1000000 && b!=q &&a!=q ) { c=q; nc = 0; }
		}
	}
	if (q == a) { na++;// cout << "kek" <<na<< endl;
	}
	if (q == b) { nb++; //cout << "keek" <<nb<< endl;
	}

	if (q == c) {
		nc++; //cout << "kekk" <<nc<< endl;
	}
}
//cout << na << ' ' << nb << ' ' << nc;
int l;
if (b > a) {
	l = a;
	a = b;
	b = l;
	l = na;
	na = nb;
	nb = l;

}

if (c > a) {
	l = a;
	a = c;
	c = l;
	l = na;
	na = nc;
	nc= l;

}

if (c > b) {
	l = b;
	b = c;
	c = l;
	l = nb;
	nb = nc;
	nc = l;

}
if (a != 1000000) {
	//cout << a << ' ' << b << ' ' << c;
	//cout << na << ' ' << nb << ' ' << nc;
	if (na+nc+nb%2 <nb+abs(na-nc)) { cout << nb % 2 + na + nc <<endl; for (int i = 0; i < n / 2; i++) cout << a << ' ' << c << ' ';  for (int i = 0; i < nb % 2; i++) cout << b; }
	else
	{
		cout <<nb+ abs(na - nc) << endl;
		if (na > nc)
		{
			for (int i = 0; i < na - nc; i++) cout << a << ' ';
		}
		else
		{
			for (int i = 0; i < nc - na; i++) cout << c << ' ';
		}
		for (int i = 0; i < n - abs(na - nc); i++) cout << b << ' ';

	}
}
if (a == 1000000) {
	if (b == 100000) { cout << n << endl; for (int i = 0; i < n; i++) cout << c << ' '; }
	else
	{
		cout << n << endl;
		for (int i = 0; i < nb; i++)cout << b << ' ';
		for (int i = 0; i < nc; i++)cout << c << ' ';
	}
}
cin >> a;
	return 0;
}


#include <vector>
#include <algorithm>
#include <fstream>
#include<string>
#include <iostream>
using namespace std;
#include <map>
# include <set>

int main(){
int n;
vector<int> x(1000000, 0), y(1000000, 0);
int a = 1000000, b = a, c = a, na = 0, nb = 0, nc = 0;
cin >> n;
int q;
for (int i = 0; i < n; i++) {
	cin >> q;
	if (a == 1000000) { a = q; na = 0; }
	else
	{
		if (b == 1000000 && a!=q) { b = q; nb = 0;  }
		else
		{
			if (c == 1000000 && b!=q &&a!=q ) { c=q; nc = 0; }
		}
	}
	if (q == a) { na++;// cout << "kek" <<na<< endl;
	}
	if (q == b) { nb++; //cout << "keek" <<nb<< endl;
	}

	if (q == c) {
		nc++; //cout << "kekk" <<nc<< endl;
	}
}
//cout << na << ' ' << nb << ' ' << nc;
int l;
if (b > a) {
	l = a;
	a = b;
	b = l;
	l = na;
	na = nb;
	nb = l;

}

if (c > a) {
	l = a;
	a = c;
	c = l;
	l = na;
	na = nc;
	nc= l;

}

if (c > b) {
	l = b;
	b = c;
	c = l;
	l = nb;
	nb = nc;
	nc = l;

}
if (a != 1000000) {
	//cout << a << ' ' << b << ' ' << c;
	//cout << na << ' ' << nb << ' ' << nc;
	if (min(nb / 2, na) + min(nb / 2, nc)+na+nc > min(2 * min(na, nc), nb)+abs(na-nc)) { cout << min(2 * min(na, nc), nb)+nb%2+abs(na-nc)<<endl; for (int i = 0; i < n / 2; i++) cout << a << ' ' << c << ' ';  for (int i = 0; i < nb % 2; i++) cout << b; }
	else
	{
		cout << min(nb / 2, na) + min(nb / 2, nc)+nb%2+na+nc << endl;
		if (na > nc)
		{
			for (int i = 0; i < na - nc; i++) cout << a << ' ';
		}
		else
		{
			for (int i = 0; i < na - nc; i++) cout << c << ' ';
		}
		for (int i = 0; i < n - abs(na - nc); i++) cout << b << ' ';

	}
}
if (a == 1000000) {
	if (b == 100000) { cout << n << endl; for (int i = 0; i < n; i++) cout << c << ' '; }
	else
	{
		cout << n << endl;
		for (int i = 0; i < nb; i++)cout << b << ' ';
		for (int i = 0; i < nc; i++)cout << c << ' ';
	}
}
cin >> a;
	return 0;
}


#include <vector>
#include <algorithm>
#include <fstream>
#include<string>
#include <iostream>
using namespace std;
#include <map>
# include <set>

int main(){
int n;
vector<int> x(1000000, 0), y(1000000, 0);
int a = 1000000, b = a, c = a, na = 0, nb = 0, nc = 0;
cin >> n;
int q;
for (int i = 0; i < n; i++) {
	cin >> q;
	if (a == 1000000) { a = q; na = 0; }
	else
	{
		if (b == 1000000 && a!=q) { b = q; nb = 0;  }
		else
		{
			if (c == 1000000 && b!=q &&a!=q ) { c=q; nc = 0; }
		}
	}
	if (q == a) { na++;// cout << "kek" <<na<< endl;
	}
	if (q == b) { nb++; //cout << "keek" <<nb<< endl;
	}

	if (q == c) {
		nc++; //cout << "kekk" <<nc<< endl;
	}
}
//cout << na << ' ' << nb << ' ' << nc;
int l;
if (b > a) {
	l = a;
	a = b;
	b = l;
	l = na;
	na = nb;
	nb = l;

}

if (c > a) {
	l = a;
	a = c;
	c = l;
	l = na;
	na = nc;
	nc= l;

}

if (c > b) {
	l = b;
	b = c;
	c = l;
	l = nb;
	nb = nc;
	nc = l;

}
if (a != 1000000) {
	//cout << a << ' ' << b << ' ' << c;
	//cout << na << ' ' << nb << ' ' << nc;
	if (na + nc + nb % 2 < nb + abs(na - nc)) { cout << nb % 2 + na + nc << endl; for (int i = 0; i < na + nb / 2; i++) cout << a << ' '; for (int i = 0; i < nc + nb / 2; i++) cout << c << ' '; for (int i = 0; i < nb % 2; i++) cout << b; }
	else
	{
		cout <<nb+ abs(na - nc) << endl;
		if (na > nc)
		{
			for (int i = 0; i < na - nc; i++) cout << a << ' ';
		}
		else
		{
			for (int i = 0; i < nc - na; i++) cout << c << ' ';
		}
		for (int i = 0; i < n - abs(na - nc); i++) cout << b << ' ';

	}
}
if (a == 1000000) {
	if (b == 100000) { cout << n << endl; for (int i = 0; i < n; i++) cout << c << ' '; }
	else
	{
		cout << n << endl;
		for (int i = 0; i < nb; i++)cout << b << ' ';
		for (int i = 0; i < nc; i++)cout << c << ' ';
	}
}
cin >> a;
	return 0;
}


#include <vector>
#include <algorithm>
#include <fstream>
#include<string>
#include <iostream>
using namespace std;
#include <map>
# include <set>

int main() {
	int n;
	vector<int> x(1000000, 0), y(1000000, 0);
	int a = 1000000, b = a, c = a, na = 0, nb = 0, nc = 0;
	cin >> n;
	int q;
	for (int i = 0; i < n; i++) {
		cin >> q;
		if (a == 1000000) { a = q; na = 0; }
		else
		{
			if (b == 1000000 && a != q) { b = q; nb = 0; }
			else
			{
				if (c == 1000000 && b != q && a != q) { c = q; nc = 0; }
			}
		}
		if (q == a) {
			na++;// cout << "kek" <<na<< endl;
		}
		if (q == b) {
			nb++; //cout << "keek" <<nb<< endl;
		}

		if (q == c) {
			nc++; //cout << "kekk" <<nc<< endl;
		}
	}
	//cout << na << ' ' << nb << ' ' << nc;
	int l;
	if (b > a) {
		l = a;
		a = b;
		b = l;
		l = na;
		na = nb;
		nb = l;

	}

	if (c > a) {
		l = a;
		a = c;
		c = l;
		l = na;
		na = nc;
		nc = l;

	}

	if (c > b) {
		l = b;
		b = c;
		c = l;
		l = nb;
		nb = nc;
		nc = l;

	}
	if (b != a - 1) {
		l = b;
		b = c;
		c = l;
		l = nb;
		nb = nc;
		nc = l;
	}
	if (a != 1000000) {
		//cout << a << ' ' << b << ' ' << c;
		//cout << na << ' ' << nb << ' ' << nc;
		if (na + nc + nb % 2 < nb + abs(na - nc)) { cout << nb % 2 + na + nc << endl; for (int i = 0; i < na + nb / 2; i++) cout << a << ' '; for (int i = 0; i < nc + nb / 2; i++) cout << c << ' '; for (int i = 0; i < nb % 2; i++) cout << b; }
		else
		{
			cout << nb + abs(na - nc) << endl;
			if (na > nc)
			{
				for (int i = 0; i < na - nc; i++) cout << a << ' ';
			}
			else
			{
				for (int i = 0; i < nc - na; i++) cout << c << ' ';
			}
			for (int i = 0; i < n - abs(na - nc); i++) cout << b << ' ';

		}
	}
	if (a == 1000000) {
		if (b == 100000) { cout << n << endl; for (int i = 0; i < n; i++) cout << c << ' '; }
		else
		{
			cout << n << endl;
			for (int i = 0; i < nb; i++)cout << b << ' ';
			for (int i = 0; i < nc; i++)cout << c << ' ';
		}
	}
	cin >> a;
	return 0;
}


#include <vector>
#include <algorithm>
#include <fstream>
#include<string>
#include <iostream>
using namespace std;
#include <map>
# include <set>

int main() {
	int n;
	vector<int> x(1000000, 0), y(1000000, 0);
	int a = 1000000, b = a, c = a, na = 0, nb = 0, nc = 0;
	cin >> n;
	int q;
	for (int i = 0; i < n; i++) {
		cin >> q;
		if (a == 1000000) { a = q; na = 0; }
		else
		{
			if (b == 1000000 && a != q) { b = q; nb = 0; }
			else
			{
				if (c == 1000000 && b != q && a != q) { c = q; nc = 0; }
			}
		}
		if (q == a) {
			na++;// cout << "kek" <<na<< endl;
		}
		if (q == b) {
			nb++; //cout << "keek" <<nb<< endl;
		}

		if (q == c) {
			nc++; //cout << "kekk" <<nc<< endl;
		}
	}
	//cout << na << ' ' << nb << ' ' << nc;
	int l;
	if (b > a ) {
		l = a;
		a = b;
		b = l;
		l = na;
		na = nb;
		nb = l;

	}

	if (c > a  ) {
		l = a;
		a = c;
		c = l;
		l = na;
		na = nc;
		nc = l;

	}

	if (c > b  ) {
		l = b;
		b = c;
		c = l;
		l = nb;
		nb = nc;
		nc = l;

	}

	if (a != 1000000) {
		//cout << a << ' ' << b << ' ' << c;
		//cout << na << ' ' << nb << ' ' << nc;
		if (na + nc + nb % 2 < nb + abs(na - nc)) { cout << nb % 2 + na + nc << endl; for (int i = 0; i < na + nb / 2; i++) cout << a << ' '; for (int i = 0; i < nc + nb / 2; i++) cout << c << ' '; for (int i = 0; i < nb % 2; i++) cout << b; }
		else
		{
			cout << nb + abs(na - nc) << endl;
			if (na > nc)
			{
				for (int i = 0; i < na - nc; i++) cout << a << ' ';
			}
			else
			{
				for (int i = 0; i < nc - na; i++) cout << c << ' ';
			}
			for (int i = 0; i < n - abs(na - nc); i++) cout << b << ' ';

		}
	}
	if (a == 1000000) {
		if (b == 1000000) {   cout << n << endl; for (int i = 0; i < n; i++) cout << c << ' '; }
		else
		{
			if (b - 1 == c) {
				cout << n << endl;
				for (int i = 0; i < nb; i++)cout << b << ' ';
				for (int i = 0; i < nc; i++)cout << c << ' ';
			}
			else
			{
				cout << abs(nb - nc) << ' ';
				for (int i = 0; i < 2 * min(nb, nc);i++)cout << b - 1 << ' ';
				for (int i = 0; i < n - 2 * min(nb, nc); i++) { if (nb < nc) cout << c << ' '; else cout << b << ' '; }

			}
		}
	}
	cout << a << ' ' << na << ' ' << b << ' ' << nb << ' ' << c << ' ' << nc;

	cin >> a;
	return 0;
}


#include <vector>
#include <algorithm>
#include <fstream>
#include<string>
#include <iostream>
using namespace std;
#include <map>
# include <set>

int main() {
	int n;
	vector<int> x(1000000, 0), y(1000000, 0);
	int a = 1000000, b = a, c = a, na = 0, nb = 0, nc = 0;
	cin >> n;
	int q;
	for (int i = 0; i < n; i++) {
		cin >> q;
		if (a == 1000000) { a = q; na = 0; }
		else
		{
			if (b == 1000000 && a != q) { b = q; nb = 0; }
			else
			{
				if (c == 1000000 && b != q && a != q) { c = q; nc = 0; }
			}
		}
		if (q == a) {
			na++;// cout << "kek" <<na<< endl;
		}
		if (q == b) {
			nb++; //cout << "keek" <<nb<< endl;
		}

		if (q == c) {
			nc++; //cout << "kekk" <<nc<< endl;
		}
	}
	//cout << na << ' ' << nb << ' ' << nc;
	int l;
	if (b > a ) {
		l = a;
		a = b;
		b = l;
		l = na;
		na = nb;
		nb = l;

	}

	if (c > a  ) {
		l = a;
		a = c;
		c = l;
		l = na;
		na = nc;
		nc = l;

	}

	if (c > b  ) {
		l = b;
		b = c;
		c = l;
		l = nb;
		nb = nc;
		nc = l;

	}

	if (a != 1000000) {
		//cout << a << ' ' << b << ' ' << c;
		//cout << na << ' ' << nb << ' ' << nc;
		if (na + nc + nb % 2 < nb + abs(na - nc)) { cout << nb % 2 + na + nc << endl; for (int i = 0; i < na + nb / 2; i++) cout << a << ' '; for (int i = 0; i < nc + nb / 2; i++) cout << c << ' '; for (int i = 0; i < nb % 2; i++) cout << b; }
		else
		{
			cout << nb + abs(na - nc) << endl;
			if (na > nc)
			{
				for (int i = 0; i < na - nc; i++) cout << a << ' ';
			}
			else
			{
				for (int i = 0; i < nc - na; i++) cout << c << ' ';
			}
			for (int i = 0; i < n - abs(na - nc); i++) cout << b << ' ';

		}
	}
	if (a == 1000000) {
		if (b == 100000) {   cout << n << endl; for (int i = 0; i < n; i++) cout << c << ' '; }
		else
		{
			if (b - 1 == c) {
				cout << n << endl;
				for (int i = 0; i < nb; i++)cout << b << ' ';
				for (int i = 0; i < nc; i++)cout << c << ' ';
			}
			else
			{
				cout << abs(nb - nc) << ' ';
				for (int i = 0; i < 2 * min(nb, nc);i++)cout << b - 1 << ' ';
				for (int i = 0; i < n - 2 * min(nb, nc); i++) { if (nb < nc) cout << c << ' '; else cout << b << ' '; }

			}
		}
	}

	cin >> a;
	return 0;
}


#include <vector>
#include <algorithm>
#include <fstream>
#include<string>
#include <iostream>
using namespace std;
#include <map>
# include <set>

int main(){
int n;
vector<int> x(1000000, 0), y(1000000, 0);
int a = 1000000, b = a, c = a, na = 0, nb = 0, nc = 0;
cin >> n;
int q;
for (int i = 0; i < n; i++) {
	cin >> q;
	if (a == 1000000) { a = q; na = 0; }
	else
	{
		if (b == 1000000 && a!=q) { b = q; nb = 0;  }
		else
		{
			if (c == 1000000 && b!=q &&a!=q ) { c=q; nc = 0; }
		}
	}
	if (q == a) { na++;// cout << "kek" <<na<< endl;
	}
	if (q == b) { nb++; //cout << "keek" <<nb<< endl;
	}

	if (q == c) {
		nc++; //cout << "kekk" <<nc<< endl;
	}
}
//cout << na << ' ' << nb << ' ' << nc;
int l;
if (b > a) {
	l = a;
	a = b;
	b = l;
	l = na;
	na = nb;
	nb = l;

}

if (c > a) {
	l = a;
	a = c;
	c = l;
	l = na;
	na = nc;
	nc= l;

}

if (c > b) {
	l = b;
	b = c;
	c = l;
	l = nb;
	nb = nc;
	nc = l;

}
if (a != 1000000) {
	//cout << a << ' ' << b << ' ' << c;
	//cout << na << ' ' << nb << ' ' << nc;
	if (na+nc < min(2 * min(na, nc), nb)+abs(na-nc)) { cout << nb % 2 + na + nc <<endl; for (int i = 0; i < n / 2; i++) cout << a << ' ' << c << ' ';  for (int i = 0; i < nb % 2; i++) cout << b; }
	else
	{
		cout << min(2 * min(na, nc), nb) + nb % 2 + abs(na - nc) << endl;
		if (na > nc)
		{
			for (int i = 0; i < na - nc; i++) cout << a << ' ';
		}
		else
		{
			for (int i = 0; i < nc - na; i++) cout << c << ' ';
		}
		for (int i = 0; i < n - abs(na - nc); i++) cout << b << ' ';

	}
}
if (a == 1000000) {
	if (b == 100000) { cout << n << endl; for (int i = 0; i < n; i++) cout << c << ' '; }
	else
	{
		cout << n << endl;
		for (int i = 0; i < nb; i++)cout << b << ' ';
		for (int i = 0; i < nc; i++)cout << c << ' ';
	}
}
cin >> a;
	return 0;
}


#include <vector>
#include <algorithm>
#include <fstream>
#include<string>
#include <iostream>
using namespace std;
#include <map>
# include <set>

int main() {
	int n;
	vector<int> x(1000000, 0), y(1000000, 0);
	int a = 1000000, b = a, c = a, na = 0, nb = 0, nc = 0;
	cin >> n;
	int q;
	for (int i = 0; i < n; i++) {
		cin >> q;
		if (a == 1000000) { a = q; na = 0; }
		else
		{
			if (b == 1000000 && a != q) { b = q; nb = 0; }
			else
			{
				if (c == 1000000 && b != q && a != q) { c = q; nc = 0; }
			}
		}
		if (q == a) {
			na++;// cout << "kek" <<na<< endl;
		}
		if (q == b) {
			nb++; //cout << "keek" <<nb<< endl;
		}

		if (q == c) {
			nc++; //cout << "kekk" <<nc<< endl;
		}
	}
	//cout << na << ' ' << nb << ' ' << nc;
	int l;
	if (b > a ) {
		l = a;
		a = b;
		b = l;
		l = na;
		na = nb;
		nb = l;

	}

	if (c > a  ) {
		l = a;
		a = c;
		c = l;
		l = na;
		na = nc;
		nc = l;

	}

	if (c > b  ) {
		l = b;
		b = c;
		c = l;
		l = nb;
		nb = nc;
		nc = l;

	}

	if (a != 1000000) {
		//cout << a << ' ' << b << ' ' << c;
		//cout << na << ' ' << nb << ' ' << nc;
		if (na + nc + nb % 2 < nb + abs(na - nc)) { cout << nb % 2 + na + nc << endl; for (int i = 0; i < na + nb / 2; i++) cout << a << ' '; for (int i = 0; i < nc + nb / 2; i++) cout << c << ' '; for (int i = 0; i < nb % 2; i++) cout << b; }
		else
		{
			cout << nb + abs(na - nc) << endl;
			if (na > nc)
			{
				for (int i = 0; i < na - nc; i++) cout << a << ' ';
			}
			else
			{
				for (int i = 0; i < nc - na; i++) cout << c << ' ';
			}
			for (int i = 0; i < n - abs(na - nc); i++) cout << b << ' ';

		}
	}
	if (a == 1000000) {
		if (b == 1000000) {   cout << n << endl; for (int i = 0; i < n; i++) cout << c << ' '; }
		else
		{
			if (b - 1 == c) {
				cout << n << endl;
				for (int i = 0; i < nb; i++)cout << b << ' ';
				for (int i = 0; i < nc; i++)cout << c << ' ';
			}
			else
			{
				cout << abs(nb - nc) << ' ';
				for (int i = 0; i < 2 * min(nb, nc);i++)cout << b - 1 << ' ';
				for (int i = 0; i < n - 2 * min(nb, nc); i++) { if (nb < nc) cout << c << ' '; else cout << b << ' '; }

			}
		}
	}
	//cout << a << ' ' << na << ' ' << b << ' ' << nb << ' ' << c << ' ' << nc;

	cin >> a;
	return 0;
}


static const bool debug=1;

#define FAST if (!debug) {std::ios::sync_with_stdio(false);cin.tie(0);}
#define FOR(a,b,c) for(int (a)=(b); (a)<(c); ++a)
#define DB(name) if(debug) cout<<#name<<"     "<<name<< "\n";
using ll = long long;
#define vi vector<INT>
int INF_int=2147483647;
ll INF_ll=9223372036854775807;
using namespace std;

// Includes
#include <iostream>
#include <vector>

// Structs

// Variables

// Functions

// Main

int main()
{
    FAST;

    int n;
    cin >> n;

    vector<int> numberz (100000,0);

    FOR(i,0,n)
    {
        cin >> numberz[i];
    }

    int minn = 1000000;
    int maxx = -1000000;
    FOR(i,0,n)
    {
        minn = min(minn, numberz[i]);
        maxx = max(maxx, numberz[i]);
    }

    if (minn==maxx)
    {
        cout << n << '\n';
        FOR(i,0,n)
        {
            cout << minn << ' ';
        }
        return 0;
    }

    /// Case 2:
    if (abs(minn-maxx)==1)
    {
        cout << n << '\n';
        FOR(i,0,n)
        {
            cout << numberz[i] << ' ';
        }
        return 0;
    }

    /// Case 3:

    /// 0:minns, 1:middles, 2:maxxs
    vector<int> numbers (3, 0);
    FOR(i,0,n)
    {
        if (numberz[i] == maxx)
            numbers[2]++;
        else if (numberz[i] == minn)
            numbers[0]++;
        else
            numbers[1]++;
    }

    int benefit1 = min(numbers[0],numbers[2])*2;
    int benefit2 = (numbers[1]/2)*2;

    if (benefit1>benefit2)
    {
        cout << n-benefit1 << '\n';

        FOR(i,0,numbers[0]-(benefit1/2))
            cout << minn << ' ';
        FOR(i,0,numbers[2]-(benefit1/2))
            cout << minn+2 << ' ';
        FOR(i,0,numbers[1]+benefit1)
            cout << minn+1 << ' ';
    }
    else
    {
        cout << n-benefit2 << '\n';

        FOR(i,0,numbers[0]+(benefit2/2))
            cout << minn << ' ';
        FOR(i,0,numbers[2]+(benefit2/2))
            cout << minn+2 << ' ';
        FOR(i,0,numbers[1]-benefit2)
            cout << minn+1 << ' ';
    }
    cout << '\n';
}


static const bool debug=1;

#define FAST if (!debug) {std::ios::sync_with_stdio(false);cin.tie(0);}
#define FOR(a,b,c) for(int (a)=(b); (a)<(c); ++a)
#define DB(name) if(debug) cout<<#name<<"     "<<name<< "\n";
using ll = long long;
#define vi vector<INT>
int INF_int=2147483647;
ll INF_ll=9223372036854775807;
using namespace std;

// Includes
#include <iostream>
#include <vector>

// Structs

// Variables

// Functions

// Main

int main()
{
    FAST;

    int n;
    cin >> n;

    vector<int> numberz (100110,0);

    FOR(i,0,n)
    {
        cin >> numberz[i];
    }

    int minn = 1000001;
    int maxx = -1000001;
    FOR(i,0,n)
    {
        minn = min(minn, numberz[i]);
        maxx = max(maxx, numberz[i]);
    }

    if (minn==maxx)
    {
        cout << n << '\n';
        FOR(i,0,n)
        {
            cout << minn << ' ';
        }
        return 0;
    }

    /// Case 2:
    if (abs(minn-maxx)==1)
    {
        cout << n << '\n';
        FOR(i,0,n)
        {
            cout << numberz[i] << ' ';
        }
        return 0;
    }

    /// Case 3:

    /// 0:minns, 1:middles, 2:maxxs
    vector<int> numbers (3, 0);
    FOR(i,0,n)
    {
        if (numberz[i] == maxx)
            numbers[2]++;
        else if (numberz[i] == minn)
            numbers[0]++;
        else
            numbers[1]++;
    }

    int benefit1 = min(numbers[0],numbers[2])*2;
    int benefit2 = (numbers[1]/2)*2;

    if (benefit1>benefit2)
    {
        cout << n-benefit1 << '\n';

        FOR(i,0,numbers[0]-(benefit1/2))
            cout << minn << ' ';
        FOR(i,0,numbers[2]-(benefit1/2))
            cout << minn+2 << ' ';
        FOR(i,0,numbers[1]+benefit1)
            cout << minn+1 << ' ';
    }
    else
    {
        cout << n-benefit2 << '\n';

        FOR(i,0,numbers[0]+(benefit1))
            cout << minn << ' ';
        FOR(i,0,numbers[2]+(benefit1))
            cout << minn+2 << ' ';
        FOR(i,0,numbers[1]-benefit1*2)
            cout << minn+1 << ' ';
    }
}


static const bool debug=1;

#define FAST if (!debug) {std::ios::sync_with_stdio(false);cin.tie(0);}
#define FOR(a,b,c) for(int (a)=(b); (a)<(c); ++a)
#define DB(name) if(debug) cout<<#name<<"     "<<name<< "\n";
using ll = long long;
#define vi vector<INT>
int INF_int=2147483647;
ll INF_ll=9223372036854775807;
using namespace std;

// Includes
#include <iostream>
#include <vector>

// Structs

// Variables

// Functions

// Main

int main()
{
    FAST;

    int n;
    cin >> n;

    vector<int> numberz (100110,0);

    FOR(i,0,n)
    {
        cin >> numberz[i];
    }

    int minn = 1000001;
    int maxx = -1000001;
    FOR(i,0,n)
    {
        minn = min(minn, numberz[i]);
        maxx = max(maxx, numberz[i]);
    }

    if (minn==maxx)
    {
        cout << n << '\n';
        FOR(i,0,n)
        {
            cout << minn << ' ';
        }
        return 0;
    }

    /// Case 2:
    if (abs(minn-maxx)==1)
    {
        cout << n << '\n';
        FOR(i,0,n)
        {
            cout << numberz[i] << ' ';
        }
        return 0;
    }

    /// Case 3:

    /// 0:minns, 1:middles, 2:maxxs
    vector<int> numbers (3, 0);
    FOR(i,0,n)
    {
        if (numberz[i] == maxx)
            numbers[2]++;
        else if (numberz[i] == minn)
            numbers[0]++;
        else
            numbers[1]++;
    }

    int benefit1 = min(numbers[0],numbers[2])*2;
    int benefit2 = (numbers[1]/2)*2;

    if (benefit1>benefit2)
    {
        cout << n-benefit1 << '\n';

        FOR(i,0,numbers[0]-(benefit1/2))
            cout << minn << ' ';
        FOR(i,0,numbers[2]-(benefit1/2))
            cout << minn+2 << ' ';
        FOR(i,0,numbers[1]+benefit1)
            cout << minn+1 << ' ';
    }
    else
    {
        cout << n-benefit2 << '\n';

        FOR(i,0,numbers[0]+(benefit1/2))
            cout << minn << ' ';
        FOR(i,0,numbers[2]+(benefit1/2))
            cout << minn+2 << ' ';
        FOR(i,0,numbers[1]-benefit1)
            cout << minn+1 << ' ';
    }
}


static const bool debug=1;

#define FAST if (!debug) {std::ios::sync_with_stdio(false);cin.tie(0);}
#define FOR(a,b,c) for(int (a)=(b); (a)<(c); ++a)
#define DB(name) if(debug) cout<<#name<<"     "<<name<< "\n";
using ll = long long;
#define vi vector<INT>
int INF_int=2147483647;
ll INF_ll=9223372036854775807;
using namespace std;

// Includes
#include <iostream>
#include <vector>

// Structs

// Variables

// Functions

// Main

int main()
{
    FAST;

    int n;
    cin >> n;

    vector<int> numberz (100000,0);

    FOR(i,0,n)
    {
        cin >> numberz[i];
    }

    int minn = 1000000;
    int maxx = -1000000;
    FOR(i,0,n)
    {
        minn = min(minn, numberz[i]);
        maxx = max(maxx, numberz[i]);
    }

    if (minn==maxx)
    {
        cout << n << '\n';
        FOR(i,0,n)
        {
            cout << minn << ' ';
        }
        return 0;
    }

    /// Case 2:
    if (abs(minn-maxx)==1)
    {
        cout << n << '\n';
        FOR(i,0,n)
        {
            cout << numberz[i] << ' ';
        }
        return 0;
    }

    /// Case 3:

    /// 0:minns, 1:middles, 2:maxxs
    vector<int> numbers (3, 0);
    FOR(i,0,n)
    {
        if (numberz[i] == maxx)
            numbers[2]++;
        else if (numberz[i] == minn)
            numbers[0]++;
        else
            numbers[1]++;
    }

    int benefit1 = min(numbers[0],numbers[2])*2;
    int benefit2 = (numbers[1]/2)*2;

    if (benefit1>benefit2)
    {
        cout << n-benefit1 << '\n';

        FOR(i,0,numbers[0]-(benefit1/2))
            cout << minn << ' ';
        FOR(i,0,numbers[2]-(benefit1/2))
            cout << minn+2 << ' ';
        FOR(i,0,numbers[1]+benefit1)
            cout << minn+1 << ' ';
    }
    else
    {
        cout << n-benefit2 << '\n';

        FOR(i,0,numbers[0]+(benefit2/2))
            cout << minn << ' ';
        FOR(i,0,numbers[2]+(benefit2/2))
            cout << minn+2 << ' ';
        FOR(i,0,numbers[1]-benefit2)
            cout << minn+1 << ' ';
    }
    cout << "asd";
}


static const bool debug=1;

#define FAST if (!debug) {std::ios::sync_with_stdio(false);cin.tie(0);}
#define FOR(a,b,c) for(int (a)=(b); (a)<(c); ++a)
#define DB(name) if(debug) cout<<#name<<"     "<<name<< "\n";
using ll = long long;
#define vi vector<INT>
int INF_int=2147483647;
ll INF_ll=9223372036854775807;
using namespace std;

// Includes
#include <iostream>
#include <vector>

// Structs

// Variables

// Functions

// Main

int main()
{
    FAST;

    int n;
    cin >> n;

    vector<int> numberz (100000,0);

    FOR(i,0,n)
    {
        cin >> numberz[i];
    }

    int minn = 1000000;
    int maxx = -1000000;
    FOR(i,0,n)
    {
        minn = min(minn, numberz[i]);
        maxx = max(maxx, numberz[i]);
    }

    if (minn==maxx)
    {
        cout << n << '\n';
        FOR(i,0,n)
        {
            cout << minn << ' ';
        }
        return 0;
    }

    /// Case 2:
    if (abs(minn-maxx)==1)
    {
        cout << n << '\n';
        FOR(i,0,n)
        {
            cout << numberz[i] << ' ';
        }
        return 0;
    }

    /// Case 3:

    /// 0:minns, 1:middles, 2:maxxs
    vector<int> numbers (3, 0);
    FOR(i,0,n)
    {
        if (numberz[i] == maxx)
            numbers[2]++;
        else if (numberz[i] == minn)
            numbers[0]++;
        else
            numbers[1]++;
    }

    int benefit1 = min(numbers[0],numbers[2])*2;
    int benefit2 = (numbers[1]/2)*2;

    if (benefit1>benefit2)
    {
        cout << n-benefit1 << '\n';

        FOR(i,0,numbers[0]-(benefit1/2))
            cout << minn << ' ';
        FOR(i,0,numbers[2]-(benefit1/2))
            cout << minn+2 << ' ';
        FOR(i,0,numbers[1]+benefit1)
            cout << minn+1 << ' ';
    }
    else
    {
        cout << n-benefit2 << '\n';

        FOR(i,0,numbers[0]+(benefit1/2))
            cout << minn << ' ';
        FOR(i,0,numbers[2]+(benefit1/2))
            cout << minn+2 << ' ';
        FOR(i,0,numbers[1]-benefit1)
            cout << minn+1 << ' ';
    }
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")// for hihocoder
#include <bits/stdc++.h>

using namespace std;

#define INF 2139062143
#define LINF 9187201950435737471
#define mem(a,v) memset(a,v,sizeof(a))
#define maxn 1000010
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define red(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define eps 1e-8
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
typedef pair<int, int> pp;

int a[maxn];
int main() {
//    ios::sync_with_stdio(false);cout.setf(ios::fixed);cout.precision(20);
#ifdef LOCAL
    freopen("/Users/huangqingwei/Documents/C++ workspace/codeforces/input.txt", "r", stdin);
//    freopen("input.txt", "r",stdin);
//    freopen("output.txt", "w",stdout);
#endif
    int n;
    scanf("%d",&n);
    rep(i,1,n)
        scanf("%d",a+i);
    int maxx = -INF,minn = INF;
    rep(i,1,n)
    {
        maxx = max(maxx, a[i]);
        minn = min(minn,a[i]);
    }
    if(abs(minn-maxx)<2)
    {
        printf("%d\n",n);
        rep(i,1,n)
            printf("%d%c",a[i],(i==n?'\n':' '));
        return 0;
    }
    int num_maxx = 0, num_minn = 0, num_mid = 0;
    rep(i,1,n)
    {
        if(a[i]==maxx)
            num_maxx++;
        else if(a[i]==minn)
            num_minn++;
        else
            num_mid++;
    }

    int ans = min(num_minn,num_maxx);
    num_minn -= ans;
    num_maxx -= ans;
    num_mid += 2*ans;
    printf("%d\n",n-2*ans);
    vector<int> res;
    if(num_minn)
        rep(i,1,num_minn)
            res.pb(minn);
    if(num_mid)
        rep(i,1,num_mid)
            res.pb((minn+maxx)/2);
    if(num_maxx)
        rep(i,1,num_maxx)
            res.pb(maxx);
    rep(i,0,res.size()-1)
        printf("%d%c",res[i],(i==res.size()-1?'\n':' '));

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")// for hihocoder
#include <bits/stdc++.h>

using namespace std;

#define INF 2139062143
#define LINF 9187201950435737471
#define mem(a,v) memset(a,v,sizeof(a))
#define maxn 1000010
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define red(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define eps 1e-8
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
typedef pair<int, int> pp;

int a[maxn];
int main() {
//    ios::sync_with_stdio(false);cout.setf(ios::fixed);cout.precision(20);
#ifdef LOCAL
    freopen("/Users/huangqingwei/Documents/C++ workspace/codeforces/input.txt", "r", stdin);
//    freopen("input.txt", "r",stdin);
//    freopen("output.txt", "w",stdout);
#endif
    int n;
    scanf("%d",&n);
    rep(i,1,n)
        scanf("%d",a+i);
    int maxx = -INF,minn = INF;
    rep(i,1,n)
    {
        maxx = max(maxx, a[i]);
        minn = min(minn,a[i]);
    }
    if(abs(minn-maxx)<2)
    {
        printf("%d\n",n);
        rep(i,1,n)
            printf("%d%c",a[i],(i==n?'\n':' '));
        return 0;
    }
    int num_maxx = 0, num_minn = 0, num_mid = 0;
    rep(i,1,n)
    {
        if(a[i]==maxx)
            num_maxx++;
        else if(a[i]==minn)
            num_minn++;
        else
            num_mid++;
    }

    int ans = min(num_minn,num_maxx);
    int ans2 = num_mid/2;
    if(ans>ans2)
    {
        num_minn -= ans;
        num_maxx -= ans;
        num_mid += 2*ans;
        printf("%d\n",n-2*ans);
        vector<int> res;
        if(num_minn)
            rep(i,1,num_minn)
                res.pb(minn);
        if(num_mid)
            rep(i,1,num_mid)
                res.pb((minn+maxx)/2);
        if(num_maxx)
            rep(i,1,num_maxx)
                res.pb(maxx);
        rep(i,0,res.size()-1)
            printf("%d%c",res[i],(i==res.size()-1?'\n':' '));
    }
    else
    {
        num_minn += ans2;
        num_maxx += ans2;
        num_mid -= 2*ans2;
        printf("%d\n",n-2*ans2);
        vector<int> res;
        if(num_minn)
            rep(i,1,num_minn)
                res.pb(minn);
        if(num_mid)
            rep(i,1,num_mid)
                res.pb((minn+maxx)/2);
        if(num_maxx)
            rep(i,1,num_maxx)
                res.pb(maxx);
        rep(i,0,res.size()-1)
            printf("%d%c",res[i],(i==res.size()-1?'\n':' '));
    }

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")// for hihocoder
#include <bits/stdc++.h>

using namespace std;

#define INF 2139062143
#define LINF 9187201950435737471
#define mem(a,v) memset(a,v,sizeof(a))
#define maxn 1000010
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define red(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define eps 1e-8
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
typedef pair<int, int> pp;

int a[maxn];
int main() {
//    ios::sync_with_stdio(false);cout.setf(ios::fixed);cout.precision(20);
#ifdef LOCAL
    freopen("/Users/huangqingwei/Documents/C++ workspace/codeforces/input.txt", "r", stdin);
//    freopen("input.txt", "r",stdin);
//    freopen("output.txt", "w",stdout);
#endif
    int n;
    scanf("%d",&n);
    rep(i,1,n)
        scanf("%d",a+i);
    int maxx = -INF,minn = INF;
    rep(i,1,n)
    {
        maxx = max(maxx, a[i]);
        minn = min(minn,a[i]);
    }
    int num_maxx = 0, num_minn = 0, num_mid = 0;
    rep(i,1,n)
    {
        if(a[i]==maxx)
            num_maxx++;
        else if(a[i]==minn)
            num_minn++;
        else
            num_mid++;
    }
    if(abs(minn-maxx)<2)
    {
        printf("%d\n",n);
        rep(i,1,n)
            printf("%d%c",a[i],(i==n?'\n':' '));
        return 0;
    }

    int ans = min(num_minn,num_maxx);
    num_minn -= ans;
    num_maxx -= ans;
    num_mid += 2*ans;
    printf("%d\n",n-2*ans);
    vector<int> res;
    if(num_minn)
        rep(i,1,num_minn)
            res.pb(minn);
    if(num_mid)
        rep(i,1,num_mid)
            res.pb(minn+1);
    if(num_maxx)
        rep(i,1,num_maxx)
            res.pb(maxx);
    rep(i,0,res.size()-1)
        printf("%d%c",res[i],(i==res.size()-1?'\n':' '));

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")// for hihocoder
#include <bits/stdc++.h>

using namespace std;

#define INF 2139062143
#define LINF 9187201950435737471
#define mem(a,v) memset(a,v,sizeof(a))
#define maxn 100010
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define red(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define eps 1e-8
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
typedef pair<int, int> pp;

int a[maxn];
int main() {
//    ios::sync_with_stdio(false);cout.setf(ios::fixed);cout.precision(20);
#ifdef LOCAL
    freopen("/Users/huangqingwei/Documents/C++ workspace/codeforces/input.txt", "r", stdin);
//    freopen("input.txt", "r",stdin);
//    freopen("output.txt", "w",stdout);
#endif
    int n;
    scanf("%d",&n);
    rep(i,1,n)
        scanf("%d",a+i);
    int maxx = -INF,minn = INF;
    rep(i,1,n)
    {
        maxx = max(maxx, a[i]);
        minn = min(minn,a[i]);
    }
    int num_maxx = 0, num_minn = 0, num_mid = 0;
    rep(i,1,n)
    {
        if(a[i]==maxx)
            num_maxx++;
        else if(a[i]==minn)
            num_minn++;
        else
            num_mid++;
    }
    if(abs(minn-maxx)<2)
    {
        printf("%d\n",n);
        rep(i,1,n)
            printf("%d%c",a[i],(i==n?'\n':' '));
        return 0;
    }

    int ans = min(num_minn,num_maxx);
    num_minn -= ans;
    num_maxx -= ans;
    num_mid += 2*ans;
    printf("%d\n",n-2*ans);
    if(num_minn)
        rep(i,1,num_minn)
            printf("%d ",minn);
    if(num_mid)
        rep(i,1,num_mid)
            printf("%d ",minn+1);
    if(num_maxx)
        rep(i,1,num_maxx)
            printf("%d ",maxx);
    printf("\n");

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")// for hihocoder
#include <bits/stdc++.h>

using namespace std;

#define INF 2139062143
#define LINF 9187201950435737471
#define mem(a,v) memset(a,v,sizeof(a))
#define maxn 1000010
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define red(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define eps 1e-8
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
typedef pair<int, int> pp;

ll a[maxn];
int main() {
    ios::sync_with_stdio(false);cout.setf(ios::fixed);cout.precision(20);
#ifdef LOCAL
    freopen("/Users/huangqingwei/Documents/C++ workspace/codeforces/input.txt", "r", stdin);
//    freopen("input.txt", "r",stdin);
//    freopen("output.txt", "w",stdout);
#endif
    int n;
    cin>>n;
    rep(i,1,n)
        cin>>a[i];
    ll maxx = -LINF,minn = LINF;
    rep(i,1,n)
    {
        maxx = max(maxx, a[i]);
        minn = min(minn,a[i]);
    }
    int num_maxx = 0, num_minn = 0, num_mid = 0;
    rep(i,1,n)
    {
        if(a[i]==maxx)
            num_maxx++;
        else if(a[i]==minn)
            num_minn++;
        else
            num_mid++;
    }
    if(abs(minn-maxx)<2)
    {
        cout<<n<<'\n';
        rep(i,1,n)
            cout<<a[i]<<(i==n?'\n':' ');
        return 0;
    }

    int ans = min(num_minn,num_maxx);
    num_minn -= ans;
    num_maxx -= ans;
    num_mid += 2*ans;
    cout<<n-2*ans<<'\n';
    vector<ll> res;
    if(num_minn)
        rep(i,1,num_minn)
            res.pb(minn);
    if(num_mid)
        rep(i,1,num_mid)
            res.pb(minn+1);
    if(num_maxx)
        rep(i,1,num_maxx)
            res.pb(maxx);
    rep(i,0,res.size()-1)
        cout<<res[i]<<(i==res.size()-1?'\n':' ');

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")// for hihocoder
#include <bits/stdc++.h>

using namespace std;

#define INF 2139062143
#define LINF 9187201950435737471
#define mem(a,v) memset(a,v,sizeof(a))
#define maxn 1000010
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define red(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define eps 1e-8
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
typedef pair<int, int> pp;

int a[maxn];
int main() {
//    ios::sync_with_stdio(false);cout.setf(ios::fixed);cout.precision(20);
#ifdef LOCAL
    freopen("/Users/huangqingwei/Documents/C++ workspace/codeforces/input.txt", "r", stdin);
//    freopen("input.txt", "r",stdin);
//    freopen("output.txt", "w",stdout);
#endif
    int n;
    scanf("%d",&n);
    rep(i,1,n)
        scanf("%d",a+i);
    int maxx = -INF,minn = INF;
    rep(i,1,n)
    {
        maxx = max(maxx, a[i]);
        minn = min(minn,a[i]);
    }
    int num_maxx = 0, num_minn = 0, num_mid = 0;
    rep(i,1,n)
    {
        if(a[i]==maxx)
            num_maxx++;
        else if(a[i]==minn)
            num_minn++;
        else
            num_mid++;
    }
    if(abs(minn-maxx)<2)
    {
        printf("%d\n",n);
        rep(i,1,n)
            printf("%d%c",a[i],(i==n?'\n':' '));
        return 0;
    }

    int ans = min(num_minn,num_maxx);
    num_minn -= ans;
    num_maxx -= ans;
    num_mid += 2*ans;
    printf("%d\n",n-2*ans);
    vector<int> res;
    if(num_minn)
        rep(i,1,num_minn)
            res.pb(minn);
    if(num_mid)
        rep(i,1,num_mid)
            res.pb(minn+1);
    if(num_maxx)
        rep(i,1,num_maxx)
            res.pb(maxx);
    sort(res.begin(),res.end());
    rep(i,0,res.size()-1)
        printf("%d%c",res[i],(i==res.size()-1?'\n':' '));

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}