#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 55;
const long long MOD = 1e9 + 7;
long long xpow(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a;
    a = a * a;
    b >>= 1;
  }
  return ret;
}
void OUT(bool res) { cout << (res ? "YES" : "NO") << endl; }
void out(bool res) { cout << (res ? "Yes" : "No") << endl; }
using ll = long long;
long long tot;
long long q;
long long ha[maxn];
long long ha2[maxn];
long long po[maxn];
mt19937 rng(time(0) ^ 19260817ULL);
uniform_int_distribution<long long> R(233, 2333);
const long long seed = R(rng);
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  po[0] = 1;
  for (long long i = 1; i < maxn; i++) po[i] = po[i - 1] * seed % MOD;
  auto init_hash = [&](long long ha[], const string& a) {
    ha[0] = a[0];
    for (long long i = 1; i < (long long)a.size(); i++) {
      ha[i] = (ha[i - 1] * seed + a[i]) % MOD;
    }
  };
  auto get_hash = [&](long long HA[], long long l, long long r) -> long long {
    long long R = HA[r];
    long long L = (l == 0 ? 0 : HA[l - 1]);
    L = L * po[r - l + 1] % MOD;
    long long ret = ((R - L) % MOD + MOD) % MOD;
    return ret;
  };
  auto gao = [&](long long len) {
    if (len == 0) return true;
    long long R1 = tot - 1;
    long long L1 = tot - len;
    long long L2 = 0;
    long long R2 = len - 1;
    return get_hash(ha, L1, R1) == get_hash(ha2, L2, R2);
  };
  string a;
  cin >> q >> a;
  init_hash(ha, a);
  tot = a.size();
  cout << a;
  q--;
  while (q--) {
    cin >> a;
    init_hash(ha2, a);
    long long L = 0, R = min(tot, (long long)a.size()), ans = 0;
    for (long long i = L; i <= R; i++) {
      if (gao(i)) ans = i;
    }
    cout << a.substr(ans);
    for (long long i = ans; i < (long long)a.size(); i++) {
      ha[tot] = (ha[tot - 1] * seed + a[i]) % MOD;
      tot++;
    }
  }
  return 0;
}
