#include <bits/stdc++.h>
using namespace std;
long long p = 47, mod = 1e9 + 13;
long long p1 = 41, mod1 = 1e9 + 7;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  string a;
  cin >> a;
  vector<pair<long long, long long>> h(a.size());
  vector<long long> Pow(1e6 + 1), Pow1(1e6 + 1);
  Pow[0] = 1;
  Pow1[0] = 1;
  for (long long i = 1; i <= 1e6; ++i)
    Pow[i] = (Pow[i - 1] * p) % mod, Pow1[i] = (Pow1[i - 1] * p1) % mod1;
  h[0] = {(a[0] - '0' + 1), (a[0] - '0' + 1)};
  for (long long i = 1; i < a.size(); ++i) {
    h[i].first = ((h[i - 1].first * p) % mod + (a[i] - '0' + 1)) % mod;
    h[i].second = ((h[i - 1].second * p1) % mod1 + (a[i] - '0' + 1)) % mod1;
  }
  for (long long _ = 1; _ < n; ++_) {
    string b;
    cin >> b;
    long long bsz = b.size();
    vector<pair<long long, long long>> tmp(bsz);
    tmp[0] = {(b[0] - '0' + 1), (b[0] - '0' + 1)};
    for (long long i = 1; i < bsz; ++i) {
      tmp[i].first = ((tmp[i - 1].first * p) % mod + (b[i] - '0' + 1)) % mod;
      tmp[i].second =
          ((tmp[i - 1].second * p1) % mod1 + (b[i] - '0' + 1)) % mod1;
    }
    long long asz = a.size();
    bool ok = false;
    long long l = 0;
    for (long long m = min(asz, bsz); m > 0; --m) {
      if (m == asz) {
        if (tmp[m - 1] == h[asz - 1]) {
          ok = true;
          l = m;
          break;
        }
        continue;
      }
      if (tmp[m - 1].first ==
              (h[asz - 1].first - (h[asz - 1 - m].first * Pow[m] % mod) + mod) %
                  mod &&
          tmp[m - 1].second ==
              (h[asz - 1].second - (h[asz - 1 - m].second * Pow1[m] % mod1) +
               mod1) %
                  mod1) {
        ok = true;
        l = m;
        break;
      }
    }
    for (long long i = l; i < bsz; ++i) a += b[i];
    for (long long i = asz; i < a.size(); ++i) {
      h.push_back(
          {(((h[i - 1].first * p) % mod + (a[i] - '0' + 1)) % mod),
           (((h[i - 1].second * p1) % mod1 + (a[i] - '0' + 1)) % mod1)});
    }
  }
  cout << a;
}
