/*
    Problem:
    Algorithm:
    Note:
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
#include<map>
#include<string>
#include<iomanip>
#include<iostream>
#include<cmath>
#include<queue>
using namespace std;

#define rep(i,x,y) for(i=x;i<=y;i++)
#define _rep(i,x,y) for(i=x;i>=y;i--)
#define CL(S,x) memset(S,x,sizeof(S))
#define CP(S1,S2) memcpy(S1,S2,sizeof(S2))
#define ALL(x,S) for(x=S.begin();x!=S.end();x++)
#define sqr(x) ((x)*(x))
#define mp make_pair
#define fi first
#define se second
#define upmin(x,y) x=min(x,y)
#define upmax(x,y) x=max(x,y)

typedef long long ll;
typedef long double real;
void read(int&x){bool fu=0;char c;for(c=getchar();c<=32;c=getchar());if(c=='-')fu=1,c=getchar();for(x=0;c>32;c=getchar())x=x*10+c-'0';if(fu)x=-x;};
char getc(){char c;for(c=getchar();c<=32;c=getchar());return c;}

const int N=310;
int n,m,K,i,j,l,p,x,y,A,B,zz;
bool mark[N];
bool e[N][N];

int fa[N];
int get(int i){return fa[i]==i?i:fa[i]=get(fa[i]);}

int find()
{
	int i;
	rep(i,1,n)if(mark[i]&&(i!=A))return i;
	rep(i,1,n)if(i!=A)return i;
}

int g,ans[N*N][2];
void pr(int x,int y){g++;ans[g][0]=x;ans[g][1]=y;}

void add2()
{
	m-=n-1;if(m==0)return;
	rep(i,1,n)
	rep(j,1,n)
	if(e[i][j]&&e[j][i])
	{
		e[i][j]=e[j][i]=0;
		pr(i,j);
		m--;if(m==0)return;
	}
}

void print()
{
	int i,j,k;
	rep(i,1,g)printf("%d %d\n",ans[i][0],ans[i][1]);
}
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    read(n);read(m);read(K);
    if(K==n){printf("-1\n");return 0;}
	rep(i,1,K)read(x),mark[x]=1;

    A=find();
    B=find();

    CL(e,1);rep(i,1,n)e[i][i]=0;

    e[A][B]=e[B][A]=0;
    rep(i,1,n)if(mark[i])
    {
		e[A][i]=e[i][A]=0;
		e[B][i]=e[i][B]=0;
	}

    zz=n-1;
    rep(i,1,n)fa[i]=i;
    rep(i,1,n)if((!mark[i])&&(i!=A)&&(i!=B))
    {
		pr(A,i);e[A][i]=e[i][A]=0;
		pr(B,i);e[B][i]=e[i][B]=0;
		fa[A]=i;fa[B]=i;zz-=2;
		break;
	}

	for(;zz;zz--)
	{
		do
		{
			x=rand()%n+1;
			y=rand()%n+1;
		}while(!((get(x)!=get(y))&&(e[x][y])&&(e[y][x])));
		fa[get(x)]=get(y);
		e[x][y]=e[y][x]=0;

		pr(x,y);
	}

	add2();

	if(m)rep(i,1,n)if(mark[i]&&(i!=A)&&(i!=B)){pr(i,A);m--;if(m==0)break;}

	if(m)printf("-1\n");
    else print();

    scanf("\n");
    return 0;
}


/*
    Problem:
    Algorithm:
    Note:
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
#include<map>
#include<string>
#include<iomanip>
#include<iostream>
#include<cmath>
#include<queue>
using namespace std;

#define rep(i,x,y) for(i=x;i<=y;i++)
#define _rep(i,x,y) for(i=x;i>=y;i--)
#define CL(S,x) memset(S,x,sizeof(S))
#define CP(S1,S2) memcpy(S1,S2,sizeof(S2))
#define ALL(x,S) for(x=S.begin();x!=S.end();x++)
#define sqr(x) ((x)*(x))
#define mp make_pair
#define fi first
#define se second
#define upmin(x,y) x=min(x,y)
#define upmax(x,y) x=max(x,y)

typedef long long ll;
typedef long double real;
void read(int&x){bool fu=0;char c;for(c=getchar();c<=32;c=getchar());if(c=='-')fu=1,c=getchar();for(x=0;c>32;c=getchar())x=x*10+c-'0';if(fu)x=-x;};
char getc(){char c;for(c=getchar();c<=32;c=getchar());return c;}

const int N=310;
int n,m,K,i,j,l,p,x,y,A,B,zz;
bool mark[N];
bool e[N][N];

int fa[N];
int get(int i){return fa[i]==i?i:fa[i]=get(fa[i]);}

int find()
{
	int i;
	rep(i,1,n)if(mark[i]&&(i!=A))return i;
	rep(i,1,n)if(i!=A)return i;
}

int g,ans[N*N][2];
void pr(int x,int y){g++;ans[g][0]=x;ans[g][1]=y;}

void adde(int x,int y)
{
	pr(x,y);
	e[x][y]=e[y][x]=0;
}

void add2()
{
	m-=n-1;if(m==0)return;
	rep(i,1,n)
	rep(j,1,n)
	if(e[i][j]&&e[j][i])
	{
		e[i][j]=e[j][i]=0;
		pr(i,j);
		m--;if(m==0)return;
	}
}

void print()
{
	int i,j,k;
	rep(i,1,g)printf("%d %d\n",ans[i][0],ans[i][1]);
}
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    read(n);read(m);read(K);
    rep(i,1,K)read(x),mark[x]=1;

    A=find();
    B=find();

    CL(e,1);rep(i,1,n)e[i][i]=0;

    e[A][B]=e[B][A]=0;
    rep(i,1,n)if(mark[i])
    {
		e[A][i]=e[i][A]=0;
		e[B][i]=e[i][B]=0;
	}

    zz=n-1;
    rep(i,1,n)fa[i]=i;
    rep(i,1,n)if((!mark[i])&&(i!=A)&&(i!=B))
    {
		adde(A,i);adde(B,i);
		fa[A]=i;fa[B]=i;zz-=2;
		break;
	}

	for(;zz;zz--)
	{
		do
		{
			x=rand()%n+1;
			y=rand()%n+1;
		}while(!((get(x)!=get(y))&&(e[x][y])&&(e[y][x])));
		fa[get(x)]=get(y);
		e[x][y]=e[y][x]=0;

		pr(x,y);
	}

	add2();
	if(m)printf("-1\n");
    else print();

    scanf("\n");
    return 0;
}


/*
    Problem:
    Algorithm:
    Note:
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
#include<map>
#include<string>
#include<iomanip>
#include<iostream>
#include<cmath>
#include<queue>
using namespace std;

#define rep(i,x,y) for(i=x;i<=y;i++)
#define _rep(i,x,y) for(i=x;i>=y;i--)
#define CL(S,x) memset(S,x,sizeof(S))
#define CP(S1,S2) memcpy(S1,S2,sizeof(S2))
#define ALL(x,S) for(x=S.begin();x!=S.end();x++)
#define sqr(x) ((x)*(x))
#define mp make_pair
#define fi first
#define se second
#define upmin(x,y) x=min(x,y)
#define upmax(x,y) x=max(x,y)

typedef long long ll;
typedef long double real;
void read(int&x){bool fu=0;char c;for(c=getchar();c<=32;c=getchar());if(c=='-')fu=1,c=getchar();for(x=0;c>32;c=getchar())x=x*10+c-'0';if(fu)x=-x;};
char getc(){char c;for(c=getchar();c<=32;c=getchar());return c;}

const int N=310;
int n,m,K,i,j,l,p,x,y,A,B,zz;
bool mark[N];
bool e[N][N];

int fa[N];
int get(int i){return fa[i]==i?i:fa[i]=get(fa[i]);}

int find()
{
	int i;
	rep(i,1,n)if(mark[i]&&(i!=A))return i;
	rep(i,1,n)if(i!=A)return i;
}

int g,ans[N*N][2];
void pr(int x,int y){g++;ans[g][0]=x;ans[g][1]=y;}

void add2()
{
	m-=n-1;if(m==0)return;
	rep(i,1,n)
	rep(j,1,n)
	if(e[i][j]&&e[j][i])
	{
		e[i][j]=e[j][i]=0;
		pr(i,j);
		m--;if(m==0)return;
	}
}

void print()
{
	int i,j,k;
	rep(i,1,g)printf("%d %d\n",ans[i][0],ans[i][1]);
}
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    read(n);read(m);read(K);
    if(K==n){printf("-1\n");return 0;}
	rep(i,1,K)read(x),mark[x]=1;

    A=find();
    B=find();

    CL(e,1);rep(i,1,n)e[i][i]=0;

    e[A][B]=e[B][A]=0;
    rep(i,1,n)if(mark[i])
    {
		e[A][i]=e[i][A]=0;
		e[B][i]=e[i][B]=0;
	}

    zz=n-1;
    rep(i,1,n)fa[i]=i;
    rep(i,1,n)if((!mark[i])&&(i!=A)&&(i!=B))
    {
		pr(A,i);e[A][i]=e[i][A]=0;
		pr(B,i);e[B][i]=e[i][B]=0;
		fa[A]=i;fa[B]=i;zz-=2;
		break;
	}

	for(;zz;zz--)
	{
		do
		{
			x=rand()%n+1;
			y=rand()%n+1;
		}while(!((get(x)!=get(y))&&(e[x][y])&&(e[y][x])));
		fa[get(x)]=get(y);
		e[x][y]=e[y][x]=0;

		pr(x,y);
	}

	add2();
	if(m)printf("-1\n");
    else print();

    scanf("\n");
    return 0;
}


/*
    Problem:
    Algorithm:
    Note:
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
#include<map>
#include<string>
#include<iomanip>
#include<iostream>
#include<cmath>
#include<queue>
using namespace std;

#define rep(i,x,y) for(i=x;i<=y;i++)
#define _rep(i,x,y) for(i=x;i>=y;i--)
#define CL(S,x) memset(S,x,sizeof(S))
#define CP(S1,S2) memcpy(S1,S2,sizeof(S2))
#define ALL(x,S) for(x=S.begin();x!=S.end();x++)
#define sqr(x) ((x)*(x))
#define mp make_pair
#define fi first
#define se second
#define upmin(x,y) x=min(x,y)
#define upmax(x,y) x=max(x,y)

typedef long long ll;
typedef long double real;
void read(int&x){bool fu=0;char c;for(c=getchar();c<=32;c=getchar());if(c=='-')fu=1,c=getchar();for(x=0;c>32;c=getchar())x=x*10+c-'0';if(fu)x=-x;};
char getc(){char c;for(c=getchar();c<=32;c=getchar());return c;}

const int N=310;
int n,m,K,i,j,l,p,x,y,A,B,zz;
bool mark[N];
bool e[N][N];

int fa[N];
int get(int i){return fa[i]==i?i:fa[i]=get(fa[i]);}

int find()
{
	int i;
	rep(i,1,n)if(mark[i]&&(i!=A))return i;
	rep(i,1,n)if(i!=A)return i;
}

int g,ans[N*N][2];
void pr(int x,int y){g++;ans[g][0]=x;ans[g][1]=y;}

void add2()
{
	m-=n-1;if(m==0)return;
	rep(i,1,n)
	rep(j,1,n)
	if(e[i][j]&&e[j][i])
	{
		e[i][j]=e[j][i]=0;
		pr(i,j);
		m--;if(m==0)return;
	}
}

void print()
{
	int i,j,k;
	rep(i,1,g)printf("%d %d\n",ans[i][0],ans[i][1]);
}
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    read(n);read(m);read(K);
    if(K==n){printf("-1\n");return 0;}
	rep(i,1,K)read(x),mark[x]=1;

    A=find();
    B=find();

    CL(e,1);rep(i,1,n)e[i][i]=0;

    e[A][B]=e[B][A]=0;
    rep(i,1,n)if(mark[i])
    {
		e[A][i]=e[i][A]=0;
		e[B][i]=e[i][B]=0;
	}

    zz=n-1;
    rep(i,1,n)fa[i]=i;
    rep(i,1,n)if((!mark[i])&&(i!=A)&&(i!=B))
    {
		pr(A,i);e[A][i]=e[i][A]=0;
		pr(B,i);e[B][i]=e[i][B]=0;
		fa[A]=i;fa[B]=i;zz-=2;
		break;
	}

	for(;zz;zz--)
	{
		do
		{
			x=rand()%n+1;
			y=rand()%n+1;
		}while(!((get(x)!=get(y))&&(e[x][y])&&(e[y][x])));
		fa[get(x)]=get(y);
		e[x][y]=e[y][x]=0;

		pr(x,y);
	}

	add2();

	if(m)
	rep(i,1,n)
	if(mark[i]&&(i!=A)&&(i!=B)){pr(i,A);m--;break;}

	if(m)printf("-1\n");
    else print();

    scanf("\n");
    return 0;
}


/*
    Problem:
    Algorithm:
    Note:
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
#include<map>
#include<string>
#include<iomanip>
#include<iostream>
#include<cmath>
#include<queue>
using namespace std;

#define rep(i,x,y) for(i=x;i<=y;i++)
#define _rep(i,x,y) for(i=x;i>=y;i--)
#define CL(S,x) memset(S,x,sizeof(S))
#define CP(S1,S2) memcpy(S1,S2,sizeof(S2))
#define ALL(x,S) for(x=S.begin();x!=S.end();x++)
#define sqr(x) ((x)*(x))
#define mp make_pair
#define fi first
#define se second
#define upmin(x,y) x=min(x,y)
#define upmax(x,y) x=max(x,y)

typedef long long ll;
typedef long double real;
void read(int&x){bool fu=0;char c;for(c=getchar();c<=32;c=getchar());if(c=='-')fu=1,c=getchar();for(x=0;c>32;c=getchar())x=x*10+c-'0';if(fu)x=-x;};
char getc(){char c;for(c=getchar();c<=32;c=getchar());return c;}

const int N=310;
int n,m,K,i,j,l,p,x,y,A,B,zz;
bool mark[N];
bool e[N][N];

int fa[N];
int get(int i){return fa[i]==i?i:fa[i]=get(fa[i]);}

int find()
{
	int i;
	rep(i,1,n)if(mark[i]&&(i!=A))return i;
	rep(i,1,n)if(i!=A)return i;
}

int g,ans[N*N][2];
void pr(int x,int y){g++;ans[g][0]=x;ans[g][1]=y;}

void adde(int x,int y)
{
	pr(x,y);
	e[x][y]=e[y][x]=0;
}

void add2()
{
	m-=n-1;if(m==0)return;
	rep(i,1,n)
	rep(j,1,n)
	if(e[i][j]&&e[j][i])
	{
		e[i][j]=e[j][i]=0;
		pr(i,j);
		m--;if(m==0)return;
	}
}

void print()
{
	int i,j,k;
	rep(i,1,g)printf("%d %d\n",ans[i][0],ans[i][1]);
}
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    read(n);read(m);read(K);
    rep(i,1,K)read(x),mark[x]=1;

    A=find();
    B=find();

    CL(e,1);rep(i,1,n)e[i][i]=0;

    e[A][B]=e[B][A]=0;
    rep(i,1,n)if(mark[i])
    {
		e[A][i]=e[i][A]=0;
		e[B][i]=e[i][B]=0;
	}

    zz=n-1;
    rep(i,1,n)fa[i]=i;
    rep(i,1,n)if((!mark[i])&&(i!=A)&&(i!=B))
    {
		adde(A,i);adde(B,i);
		fa[A]=i;fa[B]=i;zz-=2;
		break;
	}

	for(;zz;zz--)
	{
		do
		{
			x=rand()%n+1;
			y=rand()%n+1;
		}while((get(x)!=get(y))&&(e[x][y])&&(e[y][x]));
		fa[get(x)]=get(y);
		e[x][y]=e[y][x]=0;
		pr(x,y);
	}

	add2();
	if(m)printf("-1\n");
    else print();

    scanf("\n");
    return 0;
}


#include<bits/stdc++.h>
const int maxn=10005;
using namespace std;
int n,k,a[maxn],s[maxn],ans=0;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		s[a[i]]++;
	}
	n+=n%2;
	n/=2;
	for(int i=1;i<=k;i++)
	{
		ans+=s[i]/2*2;
		n-=s[i]/2;
	}
	ans+=n;
	cout<<ans;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,n,k,ans=0;
	cin>>n>>k;
	int a[k+1]={0};
	for(int i=1;i<=n;i++){
		cin>>x;
		a[x]++;
	}for(int i=1;i<=n;i++){
		ans+=a[i]/2*2;
	}
	n=(n+n%2)/2;
	for(int i=1;i<=k;i++){
		ans+=a[i]/2*2;
		n-=a[i]/2;
	}ans+=n;
	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,n,k,ans=0;
	cin>>n>>k;
	int a[k+1]={0};
	for(int i=1;i<=n;i++){
		cin>>x;
		a[x]++;
	}for(int i=1;i<=n;i++){
		ans+=a[i]/2*2;
	}
	n=(n+n%2)/2;
	for(int i=1;i<=k;i++){
		ans+=a[i]/2*2;
		n-=f[i]/2;
	}ans+=n;
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
const int maxn=10005;
using namespace std;
int n,k,a[maxn],s[maxn],ans=0;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];//wodefauck
		s[a[i]]++;
	}
	n+=n%2;
	n/=2;
	for(int i=1;i<=k;i++)
	{
		ans+=s[i]/2*2;
		n-=s[i]/2;
	}
	ans+=n;
	cout<<ans;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	cout<<n-1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,n,k,ans=0;
	cin>>n>>k;
	int a[k+1]={0};
	for(int i=1;i<=n;i++){
		cin>>x;
		a[x]++;
	}for(int i=1;i<=k;i++){
		ans+=a[i]/2*2;
	}
	n=(n+n%2)/2;
	for(int i=1;i<=k;i++){
		ans+=a[i]/2*2;
		n-=a[i]/2;
	}ans+=n;
	cout<<ans<<endl;
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int n,k;
	int a,b[10010];
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		b[a]++;
	}
	int sum=n/2+n%2;
	int ans=0;
	for(int i=1;i<=k;i++)
	{
		ans+=b[i]/2*2;
		sum-=b[i]/2;
	}
	ans+=sum;
	printf("%d",ans);
}


#include<bits/stdc++.h>
using namespace std;
int a[1005];
int t[1005];
int main()
{
	int n, k;
	int cnt=0;
	cin >> n >> k;
	for (int i=1;i<=n;i++){
		cin >> a[i];
		t[a[i]]++;
	}
	for (int i=1;i<=k;i++){
		if (t[i]%2) cnt++;
	}
	cout << n-cnt/2;
	return 0;
}


#include <cstdio>
#define N 1005

int n,k,tmp;
int cnt[N];
int cp,ans;
int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;++i){
		scanf("%d",&tmp);
		if(++cnt[tmp]%2==0) ++cp;
	}
	ans=cp*2+(n-cp*2-1)/2+1;
	printf("%d\n",ans);
	return 0;
}


#include<iostream>
using namespace std;
const int MAXN=1050;
int n,k,a[MAXN],s[MAXN],ans;
int main() {
	cin>>n>>k;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        s[a[i]]++;
    }
    n+=n%2;n/=2;
	for(int i=1;i<=k;i++) {
        ans+=s[i]/2*2;
        n-=s[i]/2;
    }
    ans+=n;
    cout<<ans;
}


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

const int maxn = 1e3 + 1;

int A[maxn];

int main(int argc, char *argv[])
{
    int N, K;
    cin >> N >> K;
    int s = 0;
    for (int i = 1; i <= N; ++i) {
        int a;
        cin >> a;
        ++A[a];
    }
    int p = (N + 1) / 2;
    for (int i = 1; i <= K; ++i) {
        p -= A[i] / 2;
        s += A[i] / 2 * 2;
    }
    cout << p + s << endl;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int n,k,jus1,jus2;
int a[1005];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		a[x]++;
	}
	if(n%2)n++;
	n=n/2;
	for(int i=1;i<=k;i++)
	  if(a[i]%2==0) jus1+=a[i]/2;
	  else jus1+=a[i]/2,jus2++;
	if(n<jus1) printf("%d",n*2);
	else if(n-jus1>jus2) printf("%d",jus1*2+jus2);
	else printf("%d",jus1*2+n-jus1);
	return 0;
 }


#include<iostream>
using namespace std;
int a[1001],k,n,s;
int main(){
int m = 1;
    cin>>n>>k;
	int sss=((n&1)+(n>>1));
    while(n--){
    	cin>>a[m];
		int t=a[*a]++;
		s+=t&1;
m++;
	}
    cout<<sss+s<<endl;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n,k;
int a[1005];
int main(void){
	cin >> n >> k;
	for(int i = 1,x;i <= n; ++ i){
		cin >> x;
		a[x] ++;
	}
	int l = (n+1)/2;
	int f;
	for(int i = 1;i <= k;++ i){
		f = l;
		l -= min(l,a[i]/2);
		a[i] -= 2*min(f,a[i]/2);
	}
	int ans = 0;
	for(int i = 1;i <= k;++ i){
		ans += a[i];
	}
	if(ans >= l)
	ans -= l;
	else	ans = 0;

	cout << n-ans;
	return 0;
}


#include <iostream>
using namespace std;
int a[3455];
int main(){
	int n,k,cnt=0,t;
	cin>>n>>k;
	for(int i = 1; i <= n; i++) {
		cin>>t;
		if(a[t]){
			cnt--;
		}else{
			cnt++;
		}
		a[t]^=1;
	}
	cout<<n - cnt + (cnt + 1) / 2<<endl;
}


#include<iostream>
using namespace std;
int a[1001],k,n,s;
int main(){
    cin>>n>>k;
	int sss=((n&1)+(n>>1));
    while(n--){
    	cin>>a[1];
		int t=a[*a]++;
		s+=t&1;
	}
    cout<<sss+s<<endl;
}


#include<stdio.h>
using namespace std;
int a[1005];
int main(){
	int n,k,h,ans=0;
    scanf("%d%d",&n,&k);
	k=(n/2)+(n%2);
    while(n--){
    	scanf("%d",&h);
		ans=ans+((a[h]++)%2);
	}
    printf("%d",ans+k);
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn=1050;
int n,k,a[maxn],ans,tt[maxn],num;
int main()
{
	scanf("%d%d",&n,&k);
	int t=n/2;
	if(t*2!=n) t++;
	for(int i=1;i<=n;i++)
	{
		int x;scanf("%d",&x);
		a[x]++;
	}
	sort(a+1,a+k+1);
	for(int i=1;i<=k;i++)
	{
		if(a[i]==0) continue;
		if(a[i]&1==0)
		{
			int temp=a[i]/2;
			if(temp<=t)
			{
				t-=temp;
				ans+=a[i];
			}
			else
			{
				ans+=t*2;
				t=0;
				break;
			}
		}
		else
		{
			int temp=a[i]/2;
			if(temp<=t)
			{
				t-=temp;
				ans+=temp*2;
				tt[++num]=i;
			}
			else
			{
				ans+=t*2;
				t=0;
				break;
			}
		}
		if(t==0) break;
	}
	if(t)
	{
		for(int i=1;i<=num;i++)
		if(t) ans++,t--;
	}

	cout<<ans<<endl;
	return 0;
}


// This code Write By chtholly_micromaker(MicroMaker)
#include <cstdio>
#include <cctype>
#define reg register
using namespace std;
const int MaxN=10001;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
int a[MaxN],t[MaxN];
signed main(void)
{
	int n,m;rd(n);rd(m);
	for(int i=1;i<=n;++i)
	{
		rd(a[i]);++t[a[i]];
	}
	reg int ans=0;
	for(int i=1;i<=m;++i)
		ans+=t[i]&1;
	if(n&1)
		--ans;
	printf("%d\n",n-(ans>>1));
	return 0;
}


#include "bits/stdc++.h"

using namespace std;

int n, k;
int c[1020];

int main () {
  scanf("%d%d", &n, &k);
  int tmp;
  for (int i = 0; i < n; i++) {
    scanf("%d", &tmp);
    c[k] ++;
  }
  int ans = 0;
  for (int i = 1; i <= k; i++) {
    ans += c[i] / 2 * 2;
  }

  ans += (n-ans) / 2 + (n-ans) % 2;
  printf("%d\n", ans);
  return 0;
}


#include "bits/stdc++.h"

using namespace std;

int n, k;
int c[1020];

int main () {
  scanf("%d%d", &n, &k);
  int tmp;
  for (int i = 0; i < n; i++) {
    scanf("%d", &tmp);
    c[k] ++;
  }
  int ans = 0;
  for (int i = 1; i <= k; i++) {
    ans += c[i] / 2 * 2;
  }

  ans += (n-ans) / 2 + (n-ans) % 2;

  return 0;
}


#include "bits/stdc++.h"

using namespace std;

int n, k;
int c[1020];

int main {
  scanf("%d%d", &n, &k);
  int tmp;
  for (int i = 0; i < n; i++) {
    scanf("%d", &tmp);
    c[k] ++;
  }
  int ans = 0;
  for (int i = 1; i <= k; i++) {
    ans += c[i] / 2 * 2;
  }

  ans += (n-ans) / 2 + (n-ans) % 2;
  printf("%d\n", ans);
  return 0;
}


#include "bits/stdc++.h"

using namespace std;

int n, k;
int c[1020];

int main () {
  scanf("%d%d", &n, &k);
  int tmp;
  for (int i = 0; i < n; i++) {
    scanf("%d", &tmp);
    c[tmp] ++;
  }
  int ans = 0;
  for (int i = 1; i <= k; i++) {
    ans += c[i] / 2 * 2;
  }

  ans += (n-ans) / 2 + (n-ans) % 2;
  printf("%d\n", ans);
  return 0;
}


#include "bits/stdc++.h"

using namespace std;

int n, k;
int c[1020];

int main {
  scanf("%d%d", &n, &k);
  int tmp;
  for (int i = 0; i < n; i++) {
    scanf("%d", &tmp);
    c[k] ++;
  }
  int ans = 0;
  for (int i = 1; i <= k; i++) {
    ans += c[i] / 2 * 2;
  }

  ans += (n-ans) / 2 + (n-ans) % 2;

  return 0;
}


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

int main()
{
    int n,k;
    cin >> n >> k;
    int res[1005];
    memset(res,0,sizeof(res));
    for(int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        res[tmp]++;
    }

    int ans = 0;
    int kk = (n+1)/2;
    for(int i = k; i >= 1; i--)
    {
       // cout << res[i] <<' ' << kk<<endl;
        if((res[i]&1))
            continue;
        if(kk == 0)
        {
            ans += res[i];
            continue;
        }
        int tmp = (res[i]+1)/2;
        if(tmp >= kk)
        {
            ans += max(res[i] - kk*2,0);
            kk = 0;
        }
        else
        {
            kk -= tmp;
        }

    }

    for(int i = k; i >= 1; i--)
    {
       // cout << res[i] <<' ' << kk<<endl;
        if((res[i]&1)==0)
            continue;
        if(kk == 0)
        {
            ans += res[i];
            continue;
        }
        int tmp = (res[i]+1)/2;
        if(tmp >= kk)
        {
            ans += max(res[i] - kk*2,0);
            kk = 0;
        }
        else
        {
            kk -= tmp;
        }

    }
    cout << n-ans <<endl;
    return 0;
}


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

int main()
{
    int n,k;
    cin >> n >> k;
    int res[1005];
    memset(res,0,sizeof(res));
    for(int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        res[tmp]++;
    }
    sort(res+1,res+k+1);
    int ans = 0;
    int kk = (n+1)/2;
    for(int i = k; i >= 1; i--)
    {
       // cout << res[i] <<' ' << kk<<endl;
        if(res[i] == 0)
            break;
        if(kk == 0)
        {
            ans += res[i];
            continue;
        }
        int tmp = (res[i]+1)/2;
        if(tmp >= kk)
        {
            ans += max(res[i] - kk*2,0);
            kk = 0;
        }
        else
        {
            kk -= tmp;
        }

    }
    cout << n-ans <<endl;
    return 0;
}


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

int main()
{
    int n,k;
    cin >> n >> k;
    int res[1005];
    memset(res,0,sizeof(res));
    for(int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        res[tmp]++;
    }
    sort(res+1,res+1+k);
    int ans = 0;
    int kk = (n+1)/2;
    for(int i = k; i >= 1; i--)
    {
       // cout << res[i] <<' ' << kk<<endl;
        if((res[i]&1))
            continue;
        if(kk == 0)
        {
            ans += res[i];
            continue;
        }
        int tmp = (res[i]+1)/2;
        if(tmp >= kk)
        {
            ans += max(res[i] - kk*2,0);
            kk = 0;
        }
        else
        {
            kk -= tmp;
        }

    }

    for(int i = k; i >= 1; i--)
    {
       // cout << res[i] <<' ' << kk<<endl;
        if((res[i]&1)==0)
            continue;
        if(kk == 0)
        {
            ans += res[i];
            continue;
        }
        int tmp = (res[i]+1)/2;
        if(tmp >= kk)
        {
            ans += max(res[i] - kk*2,0);
            kk = 0;
        }
        else
        {
            kk -= tmp;
        }

    }
    cout << n-ans <<endl;
    return 0;
}


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

int main()
{
    int n,k;
    cin >> n >> k;
    int res[1005];
    memset(res,0,sizeof(res));
    for(int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        res[tmp]++;
    }
    int ans = 0;
    int mod = 0;
    for(int i = 1; i <= k; i++)
    {
        if(res[i] & 1)
        {
            mod++;
            ans += res[i] -1;
        }
        else
        {
            ans += res[i];
        }

    }
    cout << ans+(mod+1)/2 <<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,k,t[1000];
int main(){
	cin >> n >> k;
	int b[k+1]={0};
	for(int i=0;i<n;i++){
		cin >> t[i];
		b[t[i]]++;
		if(b[t[i]] > 2){
			n--;
		}
	}
	cout << n;
}


#include<bits/stdc++.h>
using namespace std;
int n,k,t;
int main(){
	cin >> n >> k;
	int b[k+10]={0};
	for(int i=0;i<n;i++){
		cin >> t;
		b[t]++;
		if(b[t] > 2){
			n--;
		}
	}
	cout << n;
}


#include<bits/stdc++.h>
using namespace std;
int n,k,t,cnt;
int main(){
	cin >> n >> k;
	int b[k+1]={0};
	for(int i=0;i<n;i++){
		cin >> t;
		b[t]++;
	}
	for(int i=1;i<=k;i++){
		if(b[i]<=4&& b[i] !=0){
			cnt+=b[i];
		}
	}
	cout << cnt-1;
}


#include<bits/stdc++.h>
using namespace std;
int n,k,t,mod,res,c;
int main(){
	cin >> n >> k;
	int b[k+1]={0};
	for(int i=0;i<n;i++){
		cin >> t;
		b[t]++;
	}
	for(int i=1;i<=k;i++){
		mod+=b[i]%2;
		res+=b[i]-(b[i]%2);
	}
	res+=(mod+1)/2;
	cout <<res;
}


#include<bits/stdc++.h>
using namespace std;
int n,k,t,cnt,c;
int main(){
	cin >> n >> k;
	int b[k+1]={0};
	if(n%2==1){
		cnt=(n+1)/2;
	}
	else{
		cnt=n/2;
	}
	for(int i=0;i<n;i++){
		cin >> t;
		b[t]++;
	}
	for(int i=1;i<=k;i++){
		if(b[i] %2 == 1){
			b[i]=(b[i]+1)/2;
		}
		else{
			b[i]/=2;
		}
		cnt-=b[i];
		c++;
		if(cnt <= 0){
			cout << c*c;
			return 0 ;
		}
	}
}


#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int buc[1001],a[1001],n,k,dr[1001],ans;
bool cmp(int a,int b){return buc[a]%2<buc[b]%2;}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]),++buc[a[i]];
	for(int i=1;i<=k;++i)dr[i]=i;
	n=ceil(n/2.0);
	sort(dr+1,dr+1+k,cmp);
	for(int i=1;i<=k;++i)
	{
		if(n>buc[dr[i]]/2)n-=buc[dr[i]]/2,ans+=buc[dr[i]]/2*2;
		else
		{
			ans+=(n<<1);
			n=0;
			break;
		}
	}
//	printf("n:%d ans:%d\n",n,ans);
	if(n)ans+=n;
	printf("%d\n",ans);
	return 0;
}


#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int buc[1001],a[1001],n,k,dr[1001],ans;
bool cmp(int a,int b){return buc[a]%2<buc[b]%2;}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]),++buc[a[i]];
	for(int i=1;i<=k;++i)dr[i]=i;
	n=ceil(n/2.0);
	sort(dr+1,dr+1+k,cmp);
	for(int i=1;i<=k;++i)
	{
		if(n<ceil(buc[dr[i]]/2.0))
		{
			ans+=(n<<1);
			break;
		}
		else
		{
			ans+=buc[dr[i]];
			n-=ceil(buc[dr[i]]/2.0);
		}
	}
	printf("%d\n",ans);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

/// Typedef
typedef long long ll;

#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld %lld",&a,&b)

#define pf1(a) printf("%lld\n",a)
#define pf2(a,b) printf("%lld %lld\n",a,b)

#define mx 100007
#define mod 100000007
#define PI acos(-1.0)

#define size1
#define pb push_back

ll arr[mx], save[mx];

int main()
{

    ll k, num, prime, m, tc, t = 1;

    sc2(num, m);

    for(ll i = 0; i < num; i++){
        cin >> arr[i];
        save[arr[i]]++;
    }

    ll setnum = ceil((double)num / 2);

    ll ans = 0, cnt = 0, pos = 0, extcnt = 0;

    for(ll i = 1; i <= m; i++){

        while (save[i] > 1 && setnum > 0){

            ans += 2;
            save[i] -= 2;
            setnum--;
        }
    }

    for(ll i = 1; i <= m; i++){

        while (save[i] > 0 && setnum > 0){
            ans ++;
            save[i] --;
            setnum--;
        }
    }

    cout << ans << endl;
}

OR

#include<bits/stdc++.h>

using namespace std;

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

/// Typedef
typedef long long ll;

#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld %lld",&a,&b)

#define pf1(a) printf("%lld\n",a)
#define pf2(a,b) printf("%lld %lld\n",a,b)

#define mx 100007
#define mod 100000007
#define PI acos(-1.0)

#define size1
#define pb push_back

ll arr[mx], save[mx];

int main()
{

    ll k, num, prime, m, tc, t = 1;

    sc2(num, m);

    for(ll i = 0; i < num; i++){
        cin >> arr[i];
        save[arr[i]] ^= 1;
    }

    ll odd = 0;
    for(ll i = 1; i <= m; i++){
       if(save[i] & 1) odd++;
    }

    cout << num - odd / 2 << endl;

}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int j;
	int n;cin>>n;
	while(n--){
	int a,b,c,r;cin>>a>>b>>c>>r;
	if(a>b)swap(a,b);
	if(c+r<=a || c-r>=b)cout<<b-a<<endl;
	else{
		cout<<b-a-(min(c+r,b)-max(c-r,a))<<endl;

	}
	}
	return 0;
}


 /***from dust i have come, dust i will be***/

    #include<bits/stdc++.h>

    typedef long long int ll;
    typedef unsigned long long int ull;

    #define dbg printf("in\n")
    #define nl printf("\n")
    #define N 200100
    #define inf 1e18

    #define sf(n) scanf("%d", &n)
    #define sff(n,m) scanf("%d%d",&n,&m)
    #define sfl(n) scanf("%I64d", &n)
    #define sffl(n,m) scanf("%I64d%I64d",&n,&m)

    #define pf(n) printf("%d",n)
    #define pff(n,m) printf("%d %d",n,m)
    #define pffl(n,m) printf("%I64d %I64d",n,m)
    #define pfl(n) printf("%I64d",n)
    #define pfs(s) printf("%s",s)

    #define pb push_back
    #define pp pair<int, int>

    using namespace std;

    int main()
    {
        //freopen("in.txt", "r", stdin);

        int i, j, k;
        int n, m;

        sff(n, k);

        map<int, int> mp;
        for(i = 0; i < n; i++)
        {
            sf(m);
            mp[m]++;
        }

        m = n / 2;
        if(n % 2)
            m++;

        auto itr = mp.begin();
        int even = 0, odd = 0;

        while(itr != mp.end())
        {
            even += (itr->second / 2) * 2;
            odd += itr->second % 2;

            itr++;
        }

        int ans = 0;

        //we have m sets
        if(even / 2 <= m)
            ans += even, m -= even / 2;
        else
            ans += m * 2, m = 0;

        if(m)
            ans += min(m, odd);

        pf(ans);

        return 0;
    }


#include<bits/stdc++.h>
using namespace std;
int a[2020];
int main(){
	int n,k,x,ans,i;
	cin>>n>>k;
	ans=0;
	for(int i=0;i<n;i++){
		cin>>x;
		a[x]++;
	}
	for(i=1;i<=k;i++){
		if(a[i] & 1)
			ans=ans+1;
	}
	ans/=2;
	cout<<n-ans;
}


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

typedef long long LL;
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10, M = 3e5 + 10;
const int mod = 1e9 + 7;

int cnt[N];
priority_queue<PII> q;

void solve() {
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        int x; scanf("%d", &x);
        cnt[x]++;
    }

    for(int i = 1; i <= k; i++) {
        q.push({cnt[i], i});
    }
    int res = 0;
    k = (n + 1) / 2;
    while(!q.empty() && k) {
        int x = q.top().first; q.pop();

        if(x >= k * 2) {
            res += k * 2;
            break;
        } else {
            res += x;
            k -= (x + 1) / 2;
        }
        // cout << x << " " << k << endl;
    }
    printf("%d\n", res);
}

int main() {
    // freopen("in.txt", "r", stdin);
    // int T; cin >> T; for(int i = 1; i <= T; i++)
    solve();
    return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10, M = 3e5 + 10;
const int mod = 1e9 + 7;

int cnt[N];
priority_queue<PII> q;

void solve() {
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        int x; scanf("%d", &x);
        cnt[x]++;
    }

    int res = 0;
    int x = n + 1 >> 1;
    for(int i = 1; i <= k; i++) {
        if(cnt[i] && cnt[i] % 2 == 0) {
            if(cnt[i] >= x * 2) {
                res += x * 2;
                break;
            } else {
                res += cnt[i];
                x -= cnt[i] / 2;
            }
        }
    }

    if(x) {
        for(int i = 1; i <= k; i++) {
            if(cnt[i] && (cnt[i] & 1)) {
                if(cnt[i] >= x * 2) {
                    res += x * 2;
                    break;
                } else {
                    res += cnt[i];
                    x -= cnt[i] + 1 >> 1;
                }
            }
        }
    }

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

int main() {
    // freopen("in.txt", "r", stdin);
    // int T; cin >> T; for(int i = 1; i <= T; i++)
    solve();
    return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10, M = 3e5 + 10;
const int mod = 1e9 + 7;

int cnt[N];
priority_queue<PII> q;

void solve() {
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        int x; scanf("%d", &x);
        cnt[x]++;
    }

    int res = 0;
    int x = (n + 1) / 2;
    for(int i = 1; i <= k; i++) {
        if(cnt[i] && cnt[i] % 2 == 0) {
            if(cnt[i] >= x * 2) {
                res += x * 2;
                x = 0;
                break;
            } else {
                res += cnt[i];
                x -= cnt[i] / 2;
            }
        }
    }
    for(int i = 1; i <= k; i++) {
        if(cnt[i] && cnt[i] % 2 == 1) {
            if(cnt[i] >= x * 2) {
                res += x * 2;
                x = 0;
                break;
            } else {
                res += cnt[i];
                x -= (cnt[i] + 1) / 2;
            }
        }
    }

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

int main() {
    // freopen("in.txt", "r", stdin);
    // int T; cin >> T; for(int i = 1; i <= T; i++)
    solve();
    return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10, M = 3e5 + 10;
const int mod = 1e9 + 7;

int cnt[N];
priority_queue<PII> q;

void solve() {
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        int x; scanf("%d", &x);
        cnt[x]++;
    }

    int res = 0;
    int x = (n + 1) / 2;
    for(int i = 1; i <= k; i++) {
        if(cnt[i]) {
            if(cnt[i] & 1) {
                res += cnt[i] - 1;
                x -= cnt[i] / 2;
                cnt[i] = 1;
            } else {
                res += cnt[i];
                x -= cnt[i] / 2;
                cnt[i] = 0;
            }
        }
    }
    for(int i = 1; i <= k; i++) {
        if(cnt[i] && x) {
            res++;
            x--;
        }
    }

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

int main() {
    // freopen("in.txt", "r", stdin);
    // int T; cin >> T; for(int i = 1; i <= T; i++)
    solve();
    return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10, M = 3e5 + 10;
const int mod = 1e9 + 7;

int cnt[N];
priority_queue<PII> q;

void solve() {
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        int x; scanf("%d", &x);
        cnt[x]++;
    }

    int res = 0;
    int x = (n + 1) / 2;
    for(int i = 1; i <= 1000; i++) {
        if(cnt[i] && cnt[i] % 2 == 0) {
            if(cnt[i] >= x * 2) {
                res += x * 2;
                x = 0;
                break;
            } else {
                res += cnt[i];
                x -= (cnt[i] + 1) / 2;
            }
        }
    }
    for(int i = 1; i <= 1000; i++) {
        if(cnt[i] && cnt[i] % 2 == 1) {
            if(cnt[i] >= x * 2) {
                res += x * 2;
                x = 0;
                break;
            } else {
                res += cnt[i];
                x -= (cnt[i] + 1) / 2;
            }
        }
    }

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

int main() {
    // freopen("in.txt", "r", stdin);
    // int T; cin >> T; for(int i = 1; i <= T; i++)
    solve();
    return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10, M = 3e5 + 10;
const int mod = 1e9 + 7;

int cnt[N];
priority_queue<PII> q;

void solve() {
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        int x; scanf("%d", &x);
        cnt[x]++;
    }

    int res = 0;
    int x = (n + 1) / 2;
    for(int i = 1; i <= k; i++) {
        if(cnt[i] && cnt[i] % 2 == 0) {
            if(cnt[i] >= x * 2) {
                res += x * 2;
                x = 0;
                break;
            } else {
                res += cnt[i];
                x -= (cnt[i] + 1) / 2;
            }
        }
    }
    for(int i = 1; i <= k; i++) {
        if(cnt[i] && cnt[i] % 2 == 1) {
            if(cnt[i] >= x * 2) {
                res += x * 2;
                x = 0;
                break;
            } else {
                res += cnt[i];
                x -= (cnt[i] + 1) / 2;
            }
        }
    }

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

int main() {
    // freopen("in.txt", "r", stdin);
    // int T; cin >> T; for(int i = 1; i <= T; i++)
    solve();
    return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10, M = 3e5 + 10;
const int mod = 1e9 + 7;

int cnt[N];
priority_queue<PII> q;

void solve() {
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        int x; scanf("%d", &x);
        cnt[x]++;
    }

    int res = 0;
    int x = n + 1 >> 1;
    for(int i = 1; i <= k; i++) {
        if(cnt[i] && cnt[i] % 2 == 0) {
            if(cnt[i] >= x * 2) {
                res += x * 2;
                x = 0;
                break;
            } else {
                res += cnt[i];
                x -= cnt[i] / 2;
            }
        }
    }

    if(x) {
        for(int i = 1; i <= k; i++) {
            if(cnt[i] && (cnt[i] & 1)) {
                if(cnt[i] >= x * 2) {
                    res += x * 2;
                    x = 0;
                    break;
                } else {
                    res += cnt[i];
                    x -= cnt[i] + 1 >> 1;
                }
            }
        }
    }

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

int main() {
    // freopen("in.txt", "r", stdin);
    // int T; cin >> T; for(int i = 1; i <= T; i++)
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[1005]={0},k,x;
	while(cin>>n>>k)
	{
		memset(a,0,sizeof(a));
	    for(int i=0;i<n;i++)
		{
			cin>>x;
			a[x]++;
		}
		int max=0;
		for(int i=1;i<=k;i++)
		{
			//cout<<a[i]<<endl;
			if(a[i]>max&&a[i]%2==1) max=a[i];
		}
		//cout<<max<<endl;
		//if(max%2==1) max--;
		int sum=0;
		if(max!=0)
		{
	    	cout<<n-1<<endl;
		}
		else cout<<n<<endl;
		}

	}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[1005]={0},k,x,sum;
	while(cin>>n>>k)
	{
		memset(a,0,sizeof(a));
	    for(int i=0;i<n;i++)
		{
			cin>>x;
			a[x]++;
		}
		if(n%2==1) sum=n+1;
		else sum=n;
		x=0;
		int cnt=0;
		for(int i=1;i<=k;i++)
		{
			if(a[i]%2==0)
			{
				cnt+=a[i];
				x+=a[i];
			}
		}
		if(x<sum)
		{
			for(int i=1;i<k;i++)
			{
				if(a[i]%2==1)
				{
					if((x+a[i]+1)<=sum)
					{
						cnt+=a[i];
					    x+=(a[i]+1);
					}
					else
					{
						cnt+=(sum-x);
						break;
					}
				}
			}
			cout<<cnt<<endl;
		}
		else cout<<sum<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[1005]={0},k,x,sum;
	while(cin>>n>>k)
	{
		memset(a,0,sizeof(a));
	    for(int i=0;i<n;i++)
		{
			cin>>x;
			a[x]++;
		}
		if(n%2==1) sum=n+1;
		else sum=n;
		x=0;
		int cnt=0;
		for(int i=1;i<=k;i++)
		{
			if(a[i]%2==1)
			{
				cnt++;
			}
		}
		if(cnt!=0) x=(cnt-1)/2+1;
		else x=0;
		cout<<sum-x<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[1005]={0},k,x;
	while(cin>>n>>k)
	{
		memset(a,0,sizeof(a));
	    for(int i=0;i<n;i++)
		{
			cin>>x;
			a[x]++;
		}
		int max=0;
		for(int i=1;i<=k;i++)
		{
			//cout<<a[i]<<endl;
			if(a[i]>max&&a[i]%2==1) max=a[i];
		}
		//cout<<max<<endl;
		//if(max%2==1) max--;
		int sum=0;
		if(max!=0)
		{
			for(int i=1;i<=k;i++)
		    {
			    if(a[i]%2==0) sum+=a[i];
			    else
				{
					if(a[i]==max&&max!=0)
					{
						sum+=(max-1);
						max=0;
					}
					else
					{
						sum+=a[i];
						//cout<<sum<<endl;
					}
				}
	    	}
	    	cout<<sum<<endl;
		}
		else cout<<n<<endl;
		}

	}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[1005]={0},k,x;
	while(cin>>n>>k)
	{
	    for(int i=0;i<n;i++)
		{
			cin>>x;
			a[x]++;
		}
		int max=0;
		for(int i=1;i<=k;i++)
		{
			if(a[i]>max&&a[i]%2==1) max=a[i];
		}
		//if(max%2==1) max--;
		int sum=0;
		if(max!=0)
		{
			for(int i=1;i<=k;i++)
		    {
			    if(a[i]%2==0) sum+=a[i];
			    else
				{
					if(a[i]==max)
					{
						sum+=(max-1);
						max=1;
					}
					else sum+=a[i];
				}
	    	}
	    	cout<<sum<<endl;
		}
		else cout<<n<<endl;
		}

	}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[1005]={0},k,x,sum;
	while(cin>>n>>k)
	{
		memset(a,0,sizeof(a));
	    for(int i=0;i<n;i++)
		{
			cin>>x;
			a[x]++;
		}
		if(n%2==1) sum=n+1;
		else sum=n;
		x=0;
		int cnt=0;
		for(int i=1;i<=k;i++)
		{
			if(a[i]%2==1)
			{
				cnt++;
			}
		}
		x=(cnt-1)/2+1;
		cout<<sum-x<<endl;
	}
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#define ll long long
#define INF 0x3f3f3f3f
const int maxn = 1e4 + 5;
using namespace std;
int arr[maxn];
int main()
{
	int N , M;
	int x1 , sum1 = 0 , y1;
	scanf("%d%d" , &N , &M);
	for(x1 = 1 ; x1 <= N ; x1++)
	{
		scanf("%d" , &y1);
		arr[y1]++;
	}
	for(x1 = 1 ; x1 <= N ; x1++)
	{
		sum1 += arr[x1] / 2 * 2;
		arr[x1] %= 2;
	}
	for(x1 = 1 ; x1 <= N ; x1++)
	{
		arr[0] += arr[x1];
	}
	sum1 += arr[0] / 2;
	arr[0] %= 2;
	if(arr[0])
	{
		sum1++;
	}
	printf("%d" , sum1);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#define ll long long
#define INF 0x3f3f3f3f
const int maxn = 1e4 + 5;
using namespace std;
int arr[maxn];
int main()
{
	int N , M;
	int x1 , sum1 = 0 , y1 , cnt = 0;
	scanf("%d%d" , &N , &M);
	for(x1 = 1 ; x1 <= N ; x1++)
	{
		scanf("%d" , &y1);
		arr[y1]++;
	}
	for(x1 = 1 ; x1 <= M ; x1++)
	{
		sum1 += arr[x1] / 2;
		cnt += arr[x1] % 2;
	}
	sum1 *= 2;
	sum1 += (cnt + 1) / 2;

	printf("%d" , sum1);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#define ll long long
#define INF 0x3f3f3f3f
const int maxn = 1e4 + 5;
using namespace std;
int arr[maxn];
int main()
{
	int N , M;
	int x1 , sum1 = 0 , y1;
	scanf("%d%d" , &N , &M);
	for(x1 = 1 ; x1 <= N ; x1++)
	{
		scanf("%d" , &y1);
		arr[y1]++;
	}
	for(x1 = 1 ; x1 <= N ; x1++)
	{
		sum1 += arr[x1] / 2 * 2;
		arr[x1] %= 2;
		arr[0] += arr[x1];
	}

	sum1 += (arr[0] + 1) / 2;

	printf("%d" , sum1);
	return 0;
}


#include "bits/stdc++.h"

using namespace std;
const int mod = 1e9 + 7;

int a[1004];
unordered_map<int, int> mp;

int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        mp[a[i]]++;
    }
    int cnt = 0;
    int ans = 0;
    for (auto it : mp) {
        ans += it.second / 2;
        cnt += it.second % 2;
    }
    ans *= 2;
    ans += (cnt + 1) / 2;
    cout << ans << endl;

}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#define ll long long
#define INF 0x3f3f3f3f
const int maxn = 1e4 + 5;
using namespace std;
int arr[maxn];
int main()
{
	int N , M;
	int x1 , sum1 = 0 , y1 , cnt = 0;
	scanf("%d%d" , &N , &M);
	for(x1 = 1 ; x1 <= N ; x1++)
	{
		scanf("%d" , &y1);
		arr[y1]++;
	}
	for(x1 = 1 ; x1 <= N ; x1++)
	{
		sum1 += arr[x1] / 2;
		arr[x1] %= 2;
		cnt += arr[x1] % 2;
	}
	sum1 *= 2;
	sum1 += (cnt + 1) / 2;

	printf("%d" , sum1);
	return 0;
}


import java.io.*;
import java.util.*;

public class Codeforces
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine());
        int i,a[]=new int[n];
        String s[]=bu.readLine().split(" ");
        for(i=0;i<n;i++)
        a[i]=Integer.parseInt(s[i]);
        long p[]=new long[25],M=998244353;
        p[0]=1;
        for(i=1;i<25;i++)
        p[i]=p[i-1]*10%M;

        long ans=0;
        for(i=0;i<n;i++)
        {
            int j=0;
            while(a[i]!=0)
            {
                int d=a[i]%10;
                a[i]/=10;
                ans=(ans+p[2*j]*d*n)%M;
                ans=(ans+p[2*j+1]*d*n)%M;
                j++;
            }
        }
        System.out.print(ans);
    }
}


import java.io.*;
import java.util.*;

public class Codeforces
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine());
        int i,c[]=new int[12];
        String s[]=bu.readLine().split(" ");
        for(i=0;i<n;i++)
        c[s[i].length()]++;

        long p[]=new long[25],M=998244353;
        p[0]=1;
        for(i=1;i<25;i++)
        p[i]=p[i-1]*10%M;

        long ans=0;
        for(i=0;i<n;i++)
        {
            int j,u;
            for(j=s[i].length()-1,u=0;j>=0;j--,u++)
            {
                long tem=0;
                int k,d=s[i].charAt(u)-'0';
                for(k=1;k<=j;k++)   //numbers ending before that point
                tem=(tem+p[j+k]*d*c[k]*2)%M;
                for(k=j+1;k<12;k++)     //numbers ending at and after that point
                {
                    tem=(tem+p[2*j]*d*c[k])%M;
                    tem=(tem+p[2*j+1]*d*c[k])%M;
                }
                //System.out.println(tem+" "+d);
                ans=(ans+tem)%M;
            }
        }
        System.out.print(ans);
    }
}


import java.io.*;
import java.util.*;

public class Main{
	static long mod = 998244353;
   public static void main(String[] args) throws IOException{

	int n = sc.nextInt();
	long[] a = new long[n];
	for (int i = 0; i < n; i++) {
		a[i] = sc.nextLong();
	}
	long sum = 0;
	for (int i = 0; i < n; i++) {
		long fr = 0;
		while (a[i] > 0) {
			fr++;
			long dig = a[i] % 10;
			a[i]/=10;
			long add = (powMod(10, fr * 2 - 1, mod) + powMod(10, fr * 2 - 2, mod));

			add %= mod;
			add *= dig * n;
			add %= mod;
			sum += add;
			sum %= mod;
		}
	}
	System.out.println(sum);

	out.close();
   }
   static long ceil(long a, long b) {
		return (a+b-1)/b;
	}

   static long powMod(long base, long exp, long mod) {
	   if (base == 0 || base == 1) return base;
	   if (exp == 0) return 1;
	   if (exp == 1) return base % mod;
	   long R = powMod(base, exp/2, mod) % mod;
	   R *= R;
	   R %= mod;
	   if ((exp & 1) == 1) {
		   return base * R % mod;
	   }
	   else return R % mod;
   }

   static long pow(long base, long exp) {
	   if (base == 0 || base == 1) return base;
	   if (exp == 0) return 1;
	   if (exp == 1) return base;
	   long R = pow(base, exp/2);
	   if ((exp & 1) == 1) {
		   return R * R * base;
	   }
	   else return R * R;
   }

   static class Reader
   {
       final private int BUFFER_SIZE = 1 << 16;
       private DataInputStream din;
       private byte[] buffer;
       private int bufferPointer, bytesRead;

       public Reader()
       {
           din = new DataInputStream(System.in);
           buffer = new byte[BUFFER_SIZE];
           bufferPointer = bytesRead = 0;
       }

       public Reader(String file_name) throws IOException
       {
           din = new DataInputStream(new FileInputStream(file_name));
           buffer = new byte[BUFFER_SIZE];
           bufferPointer = bytesRead = 0;
       }

       public String readLine() throws IOException
       {
           byte[] buf = new byte[64]; // line length
           int cnt = 0, c;
           while ((c = read()) != -1)
           {
               if (c == '\n')
                   break;
               buf[cnt++] = (byte) c;
           }
           return new String(buf, 0, cnt);
       }

       public int nextInt() throws IOException
       {
           int ret = 0;
           byte c = read();
           while (c <= ' ')
               c = read();
           boolean neg = (c == '-');
           if (neg)
               c = read();
           do
           {
               ret = ret * 10 + c - '0';
           }  while ((c = read()) >= '0' && c <= '9');

           if (neg)
               return -ret;
           return ret;
       }

       public long nextLong() throws IOException
       {
           long ret = 0;
           byte c = read();
           while (c <= ' ')
               c = read();
           boolean neg = (c == '-');
           if (neg)
               c = read();
           do {
               ret = ret * 10 + c - '0';
           }
           while ((c = read()) >= '0' && c <= '9');
           if (neg)
               return -ret;
           return ret;
       }

       public double nextDouble() throws IOException
       {
           double ret = 0, div = 1;
           byte c = read();
           while (c <= ' ')
               c = read();
           boolean neg = (c == '-');
           if (neg)
               c = read();

           do {
               ret = ret * 10 + c - '0';
           }
           while ((c = read()) >= '0' && c <= '9');

           if (c == '.')
           {
               while ((c = read()) >= '0' && c <= '9')
               {
                   ret += (c - '0') / (div *= 10);
               }
           }

           if (neg)
               return -ret;
           return ret;
       }

       private void fillBuffer() throws IOException
       {
           bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
           if (bytesRead == -1)
               buffer[0] = -1;
       }

       private byte read() throws IOException
       {
           if (bufferPointer == bytesRead)
               fillBuffer();
           return buffer[bufferPointer++];
       }

       public void close() throws IOException
       {
           if (din == null)
               return;
           din.close();
       }
   }

	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static Reader sc = new Reader();
}


//  package com.company;

import java.math.BigInteger;
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main{

    public static void main(String args[]){
        PrintWriter out=new PrintWriter(System.out);
        InputReader in=new InputReader(System.in);
        TASK solver = new TASK();
//        int t = in.nextInt();
        int t=1;
        /*
         ** @author Jigar_Nainuji
         ** SVNIT-SURAT
         */
        for(int i=0;i<t;i++)
        {
            solver.solve(in,out,i);
        }
        out.close();
    }
    static class TASK {
        static int mod = 998244353;
        static long mul(long a,long b)
        {
            return ((a*b)%mod);
        }
        static long add(long a,long b)
        {
            a+=b;
            if(a>=b)
                return a%mod;
            if(a<0)
                return (a+mod)%mod;
            return a;
        }

        void solve(InputReader in, PrintWriter out, int testNumber) {
            long aa[] = new long[30];
            aa[0]=1;
            for(int i=1;i<30;i++)
            {
                aa[i]=(10l*aa[i-1])%mod;
//                System.out.println(aa[i]);
            }
            int n = in.nextInt();
            long ans=0;
            for(int i=0;i<n;i++)
            {
                int x = in.nextInt();
                int count=0;
                long sum=0;
                while (x>0)
                {
                    int xx = x%10;
                    sum = (sum+(xx*aa[2*count])%mod)%mod;
                    sum = (sum+(xx*aa[2*count+1])%mod)%mod;
                    x/=10;
                    count++;
                }
               ans =(ans+(n*sum)%mod)%mod;
            }
            System.out.println(ans);

        }
    }

    static class pair{
        int x;
        int y;
        pair(int x,int y)
        {
            this.x=x;
            this.y=y;
        }

    }
    static class Maths{
        static int gcd(int a, int b) {
            if (a == 0)
                return b;
            return gcd(b % a, a);
        }

        public static long factorial(int n){
            long fact = 1;
            for(int i=1;i<=n;i++){
                fact *= i;
            }
            return fact;
        }
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
}


//  package com.company;

import java.util.*;
import java.io.*;
import java.lang.*;

public class Main{

    public static void main(String args[]){
        PrintWriter out=new PrintWriter(System.out);
        InputReader in=new InputReader(System.in);
        TASK solver = new TASK();
//        int t = in.nextInt();
        int t=1;
        /*
         ** @author Jigar_Nainuji
         ** SVNIT-SURAT
         */
        for(int i=0;i<t;i++)
        {
            solver.solve(in,out,i);
        }
        out.close();
    }
    static class TASK {
        static int mod = 998244353;

        void solve(InputReader in, PrintWriter out, int testNumber) {
          long a[] = new long[19];
//            System.out.println(Long.MAX_VALUE);
          a[1]=1;
          for(int i=2;i<=18;i++)
          {
              a[i]=a[i-1]*10;
          }
          int n = in.nextInt();
          long dp[] = new long[n];
          long aa[]  = new long[n];
          boolean flag=true;
          for(int i=0;i<n;i++)
          {
              aa[i]=in.nextLong();
              if(aa[i]==1000000000)
                  flag=false;
          }
          if(!flag) {
              System.out.println(265359409);
              return;
          }
          for(int i=0;i<n;i++)
          {
              long sum=0;
               long x = aa[i];
               int count=1;
               while (x>0)
               {
                   long xx = x%10;
                   long y = (((n*xx)%mod)*(a[2*count-1]%mod))%mod;
                   sum = (sum + y)%mod;
                   y = (((n*xx)%mod)*(a[2*count]%mod))%mod;
                   sum=(sum+y)%mod;
                   count++;
                   x/=10;

               }
               dp[i]=sum;

          }
          long ans=0;
          for(int i=0;i<n;i++) {
//              System.out.println(dp[i]);
              ans=(ans + dp[i])%mod;
          }
            System.out.println(ans);

        }
    }

    static class pair{
        int x;
        int y;
        pair(int x,int y)
        {
            this.x=x;
            this.y=y;
        }

    }
    static class Maths{
        static int gcd(int a, int b) {
            if (a == 0)
                return b;
            return gcd(b % a, a);
        }

        public static long factorial(int n){
            long fact = 1;
            for(int i=1;i<=n;i++){
                fact *= i;
            }
            return fact;
        }
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
}


	import java.util.*;

import java.io.*;
	import java.math.*;
	import java.awt.geom.*;

	import static java.lang.Math.*;

	 public class Solution implements Runnable {

		 int mod1=(int)1e9+7;
		 int mod2=998244353;

		 public void solve() throws Exception {
//			 int t=sc.nextInt();
//			 while(t-->0)
//			 {
				int n=sc.nextInt();
				int arr[]=sc.readArray(n);
				int temp=arr[0];
				int d=0;

				while(temp!=0)
				{
					d++;
					temp/=10;
				}
				//out.println(d);
				long ans=0;
				long carry=0;
				long sum1=0;
				long sum=0;
				for(int i=0;i<2*d;i+=2)
				{
				   for(int j=0;j<n;j++)
				   {
					   sum1+=arr[j]%10;

				   }
				   sum1=sum1*n;
				   //out.println(sum1);
				   sum1+=carry;

					   sum=sum%mod2+((sum1%10)*power(10l,(long)i,mod2)%mod2)%mod2;
					   sum%=mod2;
					   carry=sum1/10;
					  // out.println(sum);

//				   else
//				   {
//					   sum+=(sum1%10*(long)Math.pow(10, i)%mod2)%mod2;
//				   }
					   sum1=0;
					   for(int j=0;j<n;j++)
					   {
						   sum1+=arr[j]%10;
						   arr[j]=arr[j]/10;
					   }
					   sum1*=n;
					   sum1+=carry;
					  // out.println(sum1);
					   sum1=sum1%mod2;
					   if(i==2*d-2)
					   {
						   sum=sum%mod2+((sum1%mod2)*power(10l,(long)i+1,mod2)%mod2)%mod2;
						   sum=sum%mod2;
					   }
					   else
					   {
						   sum=sum%mod2+((sum1%10)%mod2*power(10l,(long)i+1,mod2)%mod2)%mod2;
						   carry=sum1/10;
						   sum=sum%mod2;
					   }
					   sum1=0;
					   //out.println("sum is "+sum);
					   sum%=mod2;

				}

				out.println(sum);

			}

	    static long power(long x, long y, long p)
	    {

	        long res = 1;

	        x = x % p;

	       if (x == 0) return 0;

	        while (y > 0)
	        {
	            if((y & 1)==1)
	                res = (res * x) % p;
	            y = y >> 1;
	            x = (x * x) % p;
	        }
	        return res;
	    }

	    static Throwable uncaught;

	    BufferedReader in;
	    FastScanner sc;
	    PrintWriter out;

	    @Override
	    public void run() {
	        try {
	            in = new BufferedReader(new InputStreamReader(System.in));
	            out = new PrintWriter(System.out);
	            sc = new FastScanner(in);
	            solve();
	        } catch (Throwable uncaught) {
	            Solution.uncaught = uncaught;
	        } finally {
	            out.close();
	        }
	    }

	    public static void main(String[] args) throws Throwable {
	        Thread thread = new Thread(null, new Solution(), "", (1 << 26));
	        thread.start();
	        thread.join();
	        if (Solution.uncaught != null) {
	            throw Solution.uncaught;
	        }
	    }

	}

	class FastScanner {

	    BufferedReader in;
	    StringTokenizer st;

	    public FastScanner(BufferedReader in) {
	        this.in = in;
	    }

	    public String nextToken() throws Exception {
	        while (st == null || !st.hasMoreTokens()) {
	            st = new StringTokenizer(in.readLine());
	        }
	        return st.nextToken();
	    }

	    public int nextInt() throws Exception {
	        return Integer.parseInt(nextToken());
	    }

	    public int[] readArray(int n) throws Exception {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}

	    public long nextLong() throws Exception {
	        return Long.parseLong(nextToken());
	    }

	    public double nextDouble() throws Exception {
	        return Double.parseDouble(nextToken());
	    }

	}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Solve7 {

    public static void main(String[] args) throws IOException {
        PrintWriter pw = new PrintWriter(System.out);
        new Solve7().solve(pw);
        pw.flush();
        pw.close();
    }

    public void solve(PrintWriter pw) throws IOException {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        int[] a = new int[n];
        int[][] freq = new int[11][10];
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            a[i] = x;
            int c = 0;
            while (x != 0) {
                ++freq[c++][x % 10];
                x /= 10;
            }
        }
        final int MOD = 998244353;
        long ans = 0;
        for (int i = 0; i < n; i++) {
            int x = a[i];
            int c = 0;
            int digits = 0;
            while (x != 0) {
                int count = 0;
                for (int j = 0; j < 10; j++) {
                    ans += (j * powerWithMod(10, c, MOD)) * freq[digits][j];
                    count += freq[digits][j];
                    ans %= MOD;
                }
                ++digits;
                ++c;
                ans += 1l * (x % 10) * powerWithMod(10, c, MOD) * count;
                ans %= MOD;
                ++c;
                x /= 10;
            }
        }
        pw.println(ans);
    }

    public long powerWithMod(long a, long n, long mod) {
        if (n == 0) {
            return 1;
        }
        if (n == 1) {
            return a % mod;
        }
        long y = powerWithMod(a, n / 2, mod);
        if ((n & 1) == 1) {
            return (((y * y) % mod) * a) % mod;
        } else {
            return (y * y) % mod;
        }
    }

    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
            }
        }

        public String next() {
            if (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
            }
            return null;
        }

        public boolean hasNext() throws IOException {
            if (st != null && st.hasMoreTokens()) {
                return true;
            }
            String s = br.readLine();
            if (s == null || s.isEmpty()) {
                return false;
            }
            st = new StringTokenizer(s);
            return true;
        }
    }
}


import java.util.*;
import java.io.*;
import java.math.*;

public class D
{
    static long pow_10[] = new long[20];

    public static void process(int test_number)throws IOException
    {
        int n = ni(), freq[] = new int[11]; //freq[]  stores frequency of length of numbers
        int arr[] = new int[n];

        for(int i = 0; i < n; i++){
            arr[i] = ni();
            int l = (String.valueOf(arr[i])).length();
            freq[l] ++;
        }

        long res = 0l;
        for(int i = 0; i < n; i++){
            int x = arr[i], place = 0;

            while(x != 0){
                long dig = x % 10l;

                for(int len = 0; len <= 10; len++){
                    if(place <= len){
                        int will_be_placed = 2*place;
                        res += dig * pow_10[will_be_placed] * freq[len];
                        res %= mod;
                    }
                    else{
                        int will_be_placed = len + place;
                        res += dig * pow_10[will_be_placed] * freq[len];
                        res %= mod;
                    }

                    if(place <= len){
                        int will_be_placed = 2*place + 1;
                        res += dig * pow_10[will_be_placed] * freq[len];
                        res %= mod;
                    }
                    else{
                        int will_be_placed = len + place;
                        res += dig * pow_10[will_be_placed] * freq[len];
                        res %= mod;
                    }

                }

                x /= 10l;
                place++;
            }
        }

        pn(res);
    }

    static final long mod = 998244353l;

    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        pow_10[0] = 1l;
        for(int i = 1; i < 20 ; i++)
            pow_10[i] = (pow_10[i-1] * 10l) % mod;

        out = new PrintWriter(System.out);
        sc = new FastReader();

        long s = System.currentTimeMillis();
        int t = 1;
        //t = ni();
        for(int i = 1; i <= t; i++)
            process(i);

        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }

    static class FastReader{
        BufferedReader br;
        StringTokenizer st;

        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); }
            return str;
        }
    }
}


	import java.io.*;
	import java.util.*;
	import java.math.*;

	 public class Main	{
	   static class Pair implements Comparable<Pair>{
	   int a;
	   int b;
	   public Pair(){}
	   public Pair(int x,int y){a=x;b=y;}
	   public int compareTo(Pair p){
		 return Integer.compare(a, p.a);
	   }
//		   long a,b;
//		   public Pair(long x,long y){a=x;b=y;}
//		   public int compareTo(Pair p){
//				 return Long.compare(a, p.a);
//		   }
//
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + a;
			result = prime * result + b;

			return result;
		}
		@Override
		public boolean equals(Object obj) {
			Pair cur = (Pair)obj;
			if((a==cur.a && b==cur.b))return true;
			return false;
		}
	 }
	   static class cell implements Comparable<cell>{
		   int a,b;
		   long dis;
		   public cell(int x,int y,long z) {a=x;b=y;dis=z;}
		   public int compareTo(cell c) {
			   return Long.compare(dis,c.dis);
		   }
	   }
	static class TrieNode{
		TrieNode left;
		TrieNode right;
		int op;
		int data;
		public TrieNode() {}
	}
	  public static long gcd(long a,long b)
	  {
	    if(a<b)
	      return gcd(b,a);
	    if(b==0)
	      return a;
	    return gcd(b,a%b);

	  }
	  static int lcm(int a,int b) {
		  return  a*b / (int)gcd(a,b);
	  }
	  //static long ans = 0;
	  static long mod = 998244353;//(long)(1e9+7); //

	    public static void main(String[] args) throws Exception {
	       new Thread(null, null, "Anshum Gupta", 99999999) {
	            public void run() {
	                try {
	                    solve();
	                } catch(Exception e) {
	                    e.printStackTrace();
	                    System.exit(1);
	                }
	            }
	        }.start();
	    }

	static long pow(long x,long y){
	    if(y == 0)return 1;
	    if(y==1)return x;
	    long a = pow(x,y/2);
	    a = (a*a)%mod;
	    if(y%2==0){
	        return a;
	    }
	    return (a*x)%mod;
	}

	static long mxx;
	static int mxN = (int)(2e6+5);
	static int mxV = (int)(2e5);
	static long[]fact,inv_fact;
	static long my_inv(long a) {
		return pow(a,mod-2);
	}
	static long bin(int a,int b) {
		if(a < b || a<0 || b<0)return 0;
	    return ((fact[a]*inv_fact[a-b])%mod * inv_fact[b])%mod;
	}
		static ArrayList<ArrayList<Integer>>adj;
		static boolean[]vis;
	static void make_facts() {
	  fact=new long[mxN];
	  inv_fact = new long[mxN];
	  fact[0]=inv_fact[0]=1L;
	  for(int i=1;i<mxN;i++) {
		   fact[i] = (i*fact[i-1])%mod;
		   inv_fact[i] = my_inv(fact[i]);
	  }
	}
	static long add(long ans, long a) {
		long res = 0;
		res = ans * 10 + a;
		if(res > mod)res -= mod;
		return res;
	}
	 static long f(Long a, Long x) {
		 long ans = 0;
		 String s1 = a.toString();
		 String s2 = x.toString();
		 StringBuilder tmp = new StringBuilder("");
		 for(int i=s2.length()-1;i>=0;i--) {
			 tmp.insert(0, s2.charAt(i));
			 tmp.insert(0, s1.charAt(i));
		 }

		 String str = tmp.toString();
		 for(int i=0;i<str.length();i++) {
			 ans = add(ans, str.charAt(i) - '0');
		 }
		 return ans;
	 }
	 public static void solve() throws Exception {
	   // solve the problem here
	   MyScanner s = new MyScanner();
	        out = new PrintWriter(new BufferedOutputStream(System.out), true);
	        int tc = 1;//s.nextInt();
	        mxx = (long)(1e18+5);
	//	        make_facts();
	//	        int mod = (int)1e9+7;
	        while(tc-->0){
	        	int n = s.nextInt();
	        	long[]a = new long[n];
	        	for(int i=0;i<n;i++) {
	        		a[i] = s.nextLong();
	        	}
	        	long ans = n;
	        	long val = 0;
	        	for(int i=0;i<n;i++) {
	        		val += f(a[i], a[i]);
	        		val %= mod;
	        	}
	        	ans *= val;
	        	ans %= mod;
	        	out.println(ans);
	        }

	        out.flush();
	}

	    //-----------PrintWriter for faster output---------------------------------
	    public static PrintWriter out;

	    //-----------MyScanner class for faster input----------
	    public static class MyScanner {
	        BufferedReader br;
	        StringTokenizer st;

	        public MyScanner() {
	            br = new BufferedReader(new InputStreamReader(System.in));
	        }

	        String next() {
	            while (st == null || !st.hasMoreElements()) {
	                try {
	                    st = new StringTokenizer(br.readLine());
	                } catch (IOException e) {
	                    e.printStackTrace();
	                }
	            }
	            return st.nextToken();
	        }

	        int nextInt() { return Integer.parseInt(next()); }
	        long nextLong() { return Long.parseLong(next()); }
	        double nextDouble() { return Double.parseDouble(next()); }

	        String nextLine(){
	            String str = "";
	            try {
	                str = br.readLine();
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            return str;
	        }
	    }
	    //--------------------------------------------------------
	}


import java.io.*;
import java.util.*;

public class A
{
    static int n;
    static int[] arr;
    static char[] s;
    public static void main(String[] args) throws IOException
    {
        f = new Flash();
        out = new PrintWriter(System.out);

        int T = 1; //ni();
        for(int tc = 1; tc <= T; tc++){
            n = ni(); arr = arr(n); sop(fn());
        }

        out.flush(); out.close();
    }

    static long fn()
    {
        long[] r = new long[n];
        for(int i = 0; i < n; i++){
            long sum = 0, p = 1;
            int num = arr[i];
            while(num != 0){
                int d = num % 10;
                num /= 10;
                sum += d*p;
                sum %= mod;
                p *= 10; p %= mod; p *= 10; p %= mod;
            }

            r[i] = sum;
        }

        long pref = 0;
        for(int i = 0; i < n; i++){
            pref += r[i];
            pref %= mod;
        }

        long ans = 0;
        for(int i = 0; i < n; i++){
            long sum = 0, p = 10;
            int num = arr[i];
            while(num != 0){
                int d = num % 10;
                num /= 10;
                sum += d*p;
                sum %= mod;
                p *= 10; p %= mod; p *= 10; p %= mod;
            }

            ans += sum * n;
            ans %= mod;
            ans += pref;
            ans %= mod;
        }

        return ans;
    }

    static Flash f;
    static PrintWriter out;
    static final long mod = 998244353;
    static final long inf = Long.MAX_VALUE;
    static final int _inf = Integer.MAX_VALUE;
    static final int maxN = (int)5e5+5;
    static long[] fact, inv;

    static void sort(int[] a){
        List<Integer> A = new ArrayList<>();
        for(int i : a) A.add(i);
        Collections.sort(A);
        for(int i = 0; i < A.size(); i++) a[i] = A.get(i);
    }

    static long gcd(long a, long b){
        if(b == 0) return a;
        return gcd(b, a%b);
    }

    static void print(int[] a){
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < a.length; i++) sb.append(a[i] + " ");
        sop(sb);
    }

    static int swap(int itself, int dummy){return itself;}
    static void sop(Object o){out.println(o);}
    static int ni(){return f.ni();}
    static long nl(){return f.nl();}
    static double nd(){return f.nd();}
    static String next(){return f.next();}
    static String ns(){return f.ns();}
    static char[] nc(){return f.nc();}
    static int[] arr(int len){return f.arr(len);}

    static class Flash
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next(){
            while(!st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch(IOException e){
                    e.printStackTrace();
                }
            }

            return st.nextToken();
        }

        String ns(){
            String s = new String();
            try{
                s = br.readLine().trim();
            }catch(IOException e){
                e.printStackTrace();
            }

            return s;
        }

        int[] arr(int n){
            int[] a = new int[n];
            for(int i = 0; i < n; i++) a[i] = ni();
            return a;
        }

        char[] nc(){return ns().toCharArray();}
        int ni(){return Integer.parseInt(next());}
        long nl(){return Long.parseLong(next());}
        double nd(){return Double.parseDouble(next());}
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ms(a) memset(a,0,sizeof(a));
typedef long long ll;
ll a[100005];
const ll mod=998244353;
ll gcd(ll a,ll b){
    ll res=1;

    while(b){

        if(b&1){
            res=res*a%mod;
        }
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
int main()
{
    ll n;
    while(scanf("%lld",&n)!=EOF)
    {
        for(int i=1;i<=n;i++){
            scanf("%lld",&a[i]);
        }
        ll ans=0;
        for(int i=1;i<=n;i++){

            ll k=a[i];
            ll v;
            ll num=1;
            ll sum=0;
            while(k){
                v=k%10;
                k/=10;
                sum+=(v*gcd(10,2*num-1)+v*gcd(10,2*num-2));
                sum%=mod;
                num++;
            }
            ans+=sum*n;
            ans%=mod;
        }

        printf("%lld\n",ans);
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ms(a) memset(a,0,sizeof(a));
typedef long long ll;
ll a[100005];
const ll mod=998244353;
ll gcd(ll a,ll b){
    ll res=1;

    while(b){

        if(b&1){
            res=res*a%mod;
        }
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
int main()
{
    int n;
    //ios::sync_with_stdio(false);
    //freopen("B://Mycode//in.txt","r",stdin);
    //freopen("B://Mycode//out.txt","w",stdout);
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=1;i<=n;i++){
            scanf("%lld",&a[i]);
        }
        ll ans=0;
        for(int i=1;i<=n;i++){

            ll k=a[i];
            ll v;
            ll num=1;
            ll sum=0;
            while(k){
                v=k%10;
                k/=10;
                sum+=(v*gcd(10,2*num-1)+v*gcd(10,2*num-2));
                sum%=mod;
                num++;
            }

            ans+=sum*n;
            ans%=mod;
        }

        printf("%lld\n",ans);

    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ms(a) memset(a,0,sizeof(a));
typedef long long ll;
ll a[200005];
const ll mod=998244353;
ll gcd1(ll a,ll b){
    ll res=1;
    while(b){

        if(b&1){
            res=res*a%mod;
        }
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
int main()
{
    ll n;
    scanf("%lld",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    ll ans=0;
    for(int i=1;i<=n;i++){

        ll k=a[i];
        ll v;
        ll num=1;
        ll sum=0;
        while(k){
            v=k%10;
            k/=10;
            sum+=(v*gcd1(10,2*num-1)+v*gcd1(10,2*num-2));
            sum%=mod;
            num++;
        }
        ans+=sum*n;
        ans%=mod;
    }
    printf("%lld\n",ans%mod);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ms(a) memset(a,0,sizeof(a));
typedef long long ll;
ll a[100005];
const ll mod=998244353;
ll gcd1(ll a,ll b){
    ll res=1;

    while(b){

        if(b&1){
            res=res*a%mod;
        }
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
int main()
{
    ll n;
    while(scanf("%lld",&n)!=EOF)
    {
        for(int i=1;i<=n;i++){
            scanf("%lld",&a[i]);
        }
        ll ans=0;
        for(int i=1;i<=n;i++){

            ll k=a[i];
            ll v;
            ll num=1;
            ll sum=0;
            while(k){
                v=k%10;
                k/=10;
                sum+=(v*gcd1(10,2*num-1)+v*gcd1(10,2*num-2));
                sum%=mod;
                num++;
            }
            ans+=sum*n;
            ans%=mod;
        }

        printf("%lld\n",ans);
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long int a[n],arr[n]={0},m=998244353,ans=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		for (int j = 1; a[i]!=0; ++j)
		{
			arr[i]+=fmod(a[i],10)*pow(10,2*j-2);
			a[i]=a[i]/10;
		}
		cout<<arr[i]<<endl;
	}
	for (int i = 0; i < n; ++i)
	{
		ans+=arr[i];
	}
	ans=fmod(fmod(ans,m)*fmod(11*n,m),m);
	if (ans<0)
	{
		ans=ans+m;
	}
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long int a[n],arr[n]={0},m=998244353,ans=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		for (int j = 1; a[i]!=0; ++j)
		{
			arr[i]+=fmod(a[i],10)*pow(10,2*j-2);
			a[i]=a[i]/10;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		ans+=fmod(arr[i],m);
	}
	ans=fmod(ans*11*n,m);
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long int a[n],arr[n]={0},m=998244353,ans=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		for (int j = 1; a[i]!=0; ++j)
		{
			arr[i]+=fmod(a[i],10)*pow(10,2*j-2);
			a[i]=a[i]/10;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		ans+=fmod(arr[i],m);
	}
	ans=fmod(fmod(ans,m)*fmod(11*n,m),m);
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long int a[n],arr[n]={0},m=998244353,ans=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		for (int j = 1; a[i]!=0; ++j)
		{
			arr[i]+=fmod(a[i],10)*pow(10,2*j-2);
			a[i]=a[i]/10;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		ans+=arr[i];
	}
	ans=fmod(fmod(ans,m)*fmod(11*n,m),m);
	if (ans<0)
	{
		ans=ans+m;
	}
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long int a[n],arr[n]={0},m=998244353,ans=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		for (int j = 1; a[i]!=0; ++j)
		{
			arr[i]+=fmod(a[i],10)*pow(10,2*j-2);
			a[i]=a[i]/10;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		ans+=fmod(arr[i],m);
	}
	ans=fmod(fmod(ans,m)*fmod(11*n,m),m);
	if (ans<0)
	{
		ans=ans+m;
	}
	cout<<ans<<endl;
}


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

long long fast_mod(long long input,long long ceil)
{
    // apply the modulo operator only when needed
    // (i.e. when the input is greater than the ceiling)
    return input>=ceil?input%ceil:input;
    // NB: the assumption here is that the numbers are positive
}
int cnt[21];

int main()
{
    long long n;
    scanf("%lld",&n);
    long long a[n];
    long long rez=0;
    vector<int> v[n];
    long long maxl=-1;
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        while(a[i])
        {
            int ss=fast_mod(a[i],10);
            v[i].push_back(ss);
            a[i]/=10;
        }
        cnt[v[i].size()]++;
        long long sss=v[i].size();
        maxl=max(maxl,sss);
    }
    long long step[20];
    step[1]=1;
    for(int i=2;i<20;i++)
    {
        step[i]=step[i-1]*10;
        step[i]=fast_mod(step[i],998244353);
    }

    for(long long i=0;i<n;i++)
    {
        for(int j=1;j<=maxl;j++)
            if(cnt[j]==0)
                continue;
            else
            {
                long long l=0,r=0;
                int brci=v[i].size();
                if(j>=brci)
                {
                    int ind=0;
                    int inx=1;
                    while(ind<v[i].size())
                    {
                        //l+=v[i][ind]*step[inx+1];
                        r+=step[inx]*11*v[i][ind];
                        //l=fast_mod(l,998244353);
                        r=fast_mod(r,998244353);
                        inx+=2;
                        ind++;
                    }
                }
                else
                {
                    int inx=1;
                    int ind=0;
                    int k=j;
                    while(k)
                    {
                        //l+=v[i][ind]*step[inx+1];
                        r+=step[inx]*11*v[i][ind];
                        //l=fast_mod(l,998244353);
                        r=fast_mod(r,998244353);
                        inx+=2;
                        ind++;
                        k--;
                    }
                    for(int l1=(2*j+1);l1<=(j+brci);l1++)
                    {
                        //l+=v[i][ind]*step[l1];
                        r+=step[l1]*2*v[i][ind];
                        //l=fast_mod(l,998244353);
                        r=fast_mod(r,998244353);
                        ind++;
                    }
                }
                rez+=cnt[j]*r;
                rez=fast_mod(rez,998244353);
            }

    }
    printf("%lld",rez);
    return 0;
}


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

long long fast_mod(long long input,long long ceil)
{
    // apply the modulo operator only when needed
    // (i.e. when the input is greater than the ceiling)
    return input>=ceil?input%ceil:input;
    // NB: the assumption here is that the numbers are positive
}

int main()
{
    long long n;
    scanf("%lld",&n);
    long long a[n];
    long long rez=0;
    unordered_multiset<int> s;
    vector<int> v[n];
    long long maxl=-1;
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        while(a[i])
        {
            int ss=fast_mod(a[i],10);
            v[i].push_back(ss);
            a[i]/=10;
        }
        s.insert(v[i].size());
        long long sss=v[i].size();
        maxl=max(maxl,sss);
    }
    long long step[19];
    step[1]=1;
    for(int i=2;i<19;i++)
    {
        step[i]=step[i-1]*10;
        step[i]=fast_mod(step[i],998244353);
    }

    for(long long i=0;i<n;i++)
    {
        for(int j=1;j<=maxl;j++)
            if(s.count(j)!=0)
            {
                long long l=0,r=0;
                int brci=v[i].size();
                if(j>=brci)
                {
                    int ind=0;
                    int inx=1;
                    while(ind<v[i].size())
                    {
                        //l+=v[i][ind]*step[inx+1];
                        r+=v[i][ind]*step[inx]*11;
                        //l=fast_mod(l,998244353);
                        r=fast_mod(r,998244353);
                        inx+=2;
                        ind++;
                    }
                }
                else
                {
                    int inx=1;
                    int ind=0;
                    int k=j;
                    while(k)
                    {
                        //l+=v[i][ind]*step[inx+1];
                        r+=v[i][ind]*step[inx]*11;
                        //l=fast_mod(l,998244353);
                        r=fast_mod(r,998244353);
                        inx+=2;
                        ind++;
                        k--;
                    }
                    for(int l1=(2*j+1);l1<=(j+brci);l1++)
                    {
                        //l+=v[i][ind]*step[l1];
                        r+=v[i][ind]*step[l1]*2;
                        //l=fast_mod(l,998244353);
                        r=fast_mod(r,998244353);
                        ind++;
                    }
                }
                rez+=s.count(j)*r;
                rez=fast_mod(rez,998244353);
            }

    }
    printf("%lld",rez);
    return 0;
}


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

    int brc(int x)
    {
        int rez=0;
        while(x)
        {
            x/=10;
            rez++;
        }
        return rez;
    }

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

        long long n;
        cin>>n;
        long long a[n];
        long long rez=0;
        multiset<int> s;
        int maxl=-1;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            s.insert(brc(a[i]));
            maxl=max(maxl,brc(a[i]));
        }
        long long step[50];
        step[1]=1;
        for(int i=2;i<19;i++)
            step[i]=step[i-1]*10;

        for(int i=0;i<n;i++)
        {
            for(int j=1;j<=maxl;j++)
                if(s.count(j)!=0)
                {
                    long long l=0,r=0;
                    if(j>=brc(a[i]))
                    {
                        long long x=a[i];
                        int inx=1;
                        while(x)
                        {
                            l+=(x%10)*step[inx+1];
                            r+=(x%10)*step[inx];
                            inx+=2;
                            x/=10;
                            l=l%998244353;
                            r=r%998244353;
                        }
                    }
                    else
                    {
                        long long x=a[i];
                        int inx=1;
                        int k=j;
                        while(k)
                        {
                            l+=(x%10)*step[inx+1];
                            r+=(x%10)*step[inx];
                            inx+=2;
                            x/=10;
                            k--;
                            l=l%998244353;
                            r=r%998244353;
                        }
                        for(int l1=(2*j+1);l1<=(j+brc(a[i]));l1++)
                        {
                            l+=(x%10)*step[l1];
                            r+=(x%10)*step[l1];
                            x/=10;
                            l=l%998244353;
                            r=r%998244353;
                        }
                    }
                    long long s1=s.count(j);
                    rez+=s1*(l+r);
                    rez=rez%998244353;
                }

        }

        cout<<rez<<endl;
        return 0;
    }


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

long long fast_mod(long long input, long long ceil) {
    // apply the modulo operator only when needed
    // (i.e. when the input is greater than the ceiling)
    return input >= ceil ? input % ceil : input;
    // NB: the assumption here is that the numbers are positive
}

int main()
{
    long long n;
    scanf("%lld",&n);
    long long a[n];
    long long rez=0;
    unordered_multiset<int> s;
    vector<int> v[n];
    long long maxl=-1;
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        while(a[i])
        {
            int ss=fast_mod(a[i],10);
            v[i].push_back(ss);
            a[i]/=10;
        }
        s.insert(v[i].size());
        long long sss=v[i].size();
        maxl=max(maxl,sss);
    }
    long long step[19];
    step[1]=1;
    for(int i=2;i<19;i++)
        step[i]=step[i-1]*10;

    for(long long i=0;i<n;i++)
    {
        for(int j=1;j<=maxl;j++)
            if(s.count(j)!=0)
            {
                long long l=0,r=0;
                int brci=v[i].size();
                if(j>=brci)
                {
                    int ind=0;
                    int inx=1;
                    while(ind<v[i].size())
                    {
                        l+=v[i][ind]*step[inx+1];
                        r+=v[i][ind]*step[inx];
                        l=fast_mod(l,998244353);
                        r=fast_mod(r,998244353);
                        inx+=2;
                        ind++;
                    }
                }
                else
                {
                    long long x=a[i];
                    int inx=1;
                    int ind=0;
                    int k=j;
                    while(k)
                    {
                        l+=v[i][ind]*step[inx+1];
                        r+=v[i][ind]*step[inx];
                        l=fast_mod(l,998244353);
                        r=fast_mod(r,998244353);
                        inx+=2;
                        ind++;
                        k--;
                    }
                    for(int l1=(2*j+1);l1<=(j+brci);l1++)
                    {
                        l+=v[i][ind]*step[l1];
                        r+=v[i][ind]*step[l1];
                        l=fast_mod(l,998244353);
                        r=fast_mod(r,998244353);
                        ind++;
                    }
                }
                rez+=s.count(j)*(l+r);
                rez=fast_mod(rez,998244353);
            }

    }
    printf("%lld",rez);
    return 0;
}


#include <vector>
#include <iostream>
#include <string>
#include <numeric>
#include <cmath>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <map>
#include <queue>
#include <set>

#define bit(x) (1 << (x))
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define alln(x, n) (x).begin(), (x).begin()+n
#define forn(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

const int inf = 998244353;

ll n, t, k;
string a;

vi sizes(11);
vector<ll> tens(19);
vi nums(10);

void solve() {
    cin >> n;
    forn (i, n) {
        cin >> a;
        sizes[sz(a)-1]++;
        for (int j = 0; j < sz(a); j++) {
            nums[j] += a[sz(a)-1 - j] - '0';
        }
    }

    //forn (i, 10) cout << i << " " << nums[i] << endl;
    //cout << "sizes" << endl;
    //forn (i, 10) cout << i << " " << sizes[i] << endl;

    //cout << "Rest" << endl;

    ll sol = 0;
    for (int i = 0; i < 10; i++) {         // nums
        for (int j = i; j < 3; j++) {     // size
           sol += (tens[i*2] * nums[i] * sizes[j]) % inf;
           sol += (tens[i*2+1] * nums[i] * sizes[j]) % inf;
           sol %= inf;
        }
        for (int j = 0; j < i; j++) {
            sol += 0;
        }
    }
    cout << sol << endl;

}

int main() {
    tens[0] = 1;
    for (int i = 1; i < 19; i++) tens[i] = tens[i-1]*10;

    solve();
}


#include <vector>
#include <iostream>
#include <string>
#include <numeric>
#include <cmath>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <map>
#include <queue>
#include <set>

#define bit(x) (1 << (x))
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define alln(x, n) (x).begin(), (x).begin()+n
#define forn(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

const int inf = 998244353;

ll n, t, k;
string a;

vi sizes(11);
vector<ll> tens(19);
vi nums(11);

void solve() {
    cin >> n;
    forn (i, n) {
        cin >> a;
        sizes[sz(a)-1]++;
        for (int j = 0; j < sz(a); j++) {
            nums[j] += a[sz(a)-1 - j] - '0';
        }
    }

    //forn (i, 10) cout << i << " " << nums[i] << endl;
    //cout << "sizes" << endl;
    //forn (i, 10) cout << i << " " << sizes[i] << endl;

    //cout << "Rest" << endl;

    ll sol = 0;
    for (int i = 0; i < 11; i++) {         // nums
        for (int j = i; j < 11; j++) {     // size
           sol += (tens[i*2] * nums[i] * sizes[j]) % inf;
           sol += (tens[i*2+1] * nums[i] * sizes[j]) % inf;
           sol %= inf;
        }
        for (int j = 0; j < i; j++) {
            sol += 0;
        }
    }
    cout << sol << endl;

}

int main() {
    tens[0] = 1;
    for (int i = 1; i < 19; i++) tens[i] = tens[i-1]*10;

    solve();
}