#include <bits/stdc++.h>
using namespace std;
long long f = 0;
int main() {
  long long n;
  cin >> n;
  vector<string> a;
  long long h[11] = {0};
  for (long long i = 0; i < n; i++) {
    string x;
    cin >> x;
    a.push_back(x);
    h[a[a.size() - 1].size()]++;
  }
  long long dp[1000001] = {0};
  for (long long i = 0; i < n; i++) {
    for (long long j = a[i].size() - 1; j >= 0; j--) {
      long long pos = a[i].size() - j;
      for (long long k = 1; k <= 10; k++) {
        if (pos > min(pos, k)) {
          dp[pos + min(pos, k)] += (2 * h[k] * (a[i][j] - 48));
        } else {
          dp[pos + min(pos, k)] += (h[k] * (a[i][j] - 48));
          dp[pos + min(pos, k) - 1] += (h[k] * (a[i][j] - 48));
        }
      }
    }
  }
  long long maxi = 0;
  for (long long i = 1; i <= 100000; i++) {
    if (dp[i] > 0) maxi = max(maxi, i);
  }
  string ans;
  for (int i = 1; i < maxi; i++) {
    long long rem = dp[i] % 10;
    long long c = dp[i] / 10;
    ans.push_back(rem + 48);
    dp[i + 1] += c;
  }
  reverse(ans.begin(), ans.end());
  cout << dp[maxi] << ans;
}
