#include <bits/stdc++.h>
const long long N = 500005;
const long long mod = 998244353;
using namespace std;
long long mo(string num, long long a) {
  long long res = 0;
  for (long long i = 0; i < num.length(); i++)
    res = (res * 10 + (long long)num[i] - '0') % a;
  return res;
}
void solve() {
  long long n, m, k, x = 0, y = 0, c = 0, q, ans = 0;
  cin >> n;
  string s[n], st;
  for (long long i = 0; i < n; ++i) {
    cin >> s[i];
  }
  m = s[0].size();
  for (long long j = m - 1; j >= 0; j--) {
    x = 0;
    for (long long i = 0; i < n; ++i) {
      x += (s[i][j] - '0');
    }
    x *= n;
    q = x;
    x = (x + y);
    k = x % 10;
    y = x / 10;
    st += (k + '0');
    q = (q + y);
    k = q % 10;
    y = q / 10;
    st += (k + '0');
  }
  while (y > 0) {
    k = y % 10;
    y = y / 10;
    st += (k + '0');
  }
  reverse(st.begin(), st.end());
  cout << mo(st, mod) << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
