#include <bits/stdc++.h>
using namespace std;
long long a[1005], dp[100], mod = 998244353;
char ss[100500][20];
int lenss[100500];
long long qpower(long long x, long long y) {
  long long sum = 1;
  while (y) {
    if (y & 1) sum = (sum * x) % mod;
    x = (x * x) % mod;
    y >>= 1;
  }
  return sum;
}
int main() {
  int n;
  long long x;
  while (~scanf("%d%", &n)) {
    memset(dp, 0, sizeof(dp));
    memset(a, 0, sizeof(a));
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%s", &ss[i]);
      lenss[i] = strlen(ss[i]);
      dp[lenss[i]]++;
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= 12; j++) {
        if (dp[j] == 0) continue;
        for (int s = 1; s <= j && s <= lenss[i]; s++) {
          a[s * 2] =
              (a[s * 2] + ((ss[i][lenss[i] - s] - '0') * dp[j]) % mod) % mod;
        }
        for (int s = j + 1; s <= lenss[i]; s++) {
          a[j * 2 + s - j] =
              (a[j * 2 + s - j] + ((ss[i][lenss[i] - s] - '0') * dp[j]) % mod) %
              mod;
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= 12; j++) {
        if (dp[j] == 0) continue;
        for (int s = 1; s <= j + 1 && s <= lenss[i]; s++) {
          a[(s - 1) * 2 + 1] = (a[(s - 1) * 2 + 1] +
                                ((ss[i][lenss[i] - s] - '0') * dp[j]) % mod) %
                               mod;
        }
        for (int s = j + 2; s <= lenss[i]; s++) {
          a[(j)*2 + s - j] =
              (a[(j)*2 + s - j] + ((ss[i][lenss[i] - s] - '0') * dp[j]) % mod);
        }
      }
    }
    long long t = 1;
    for (int i = 1; i <= 22; i++) {
      sum = (sum + (a[i] * t) % mod) % mod;
      t = (t * 10) % mod;
    }
    printf("%lld\n", sum);
  }
}
