#include <bits/stdc++.h>
using namespace std;
long long n;
long long H = 9973, H2 = 1145143;
long long mod, mod2;
long long beki[1000005], beki2[1000005];
pair<long long, long long> hashA[1000005], hashS[1000005];
long long getrand() {
  return rand() + (long long)RAND_MAX * rand() +
         (long long)RAND_MAX * RAND_MAX * rand() +
         (long long)RAND_MAX * RAND_MAX * RAND_MAX * rand();
}
void makeHash(string &s, pair<long long, long long> hash[], long long l,
              long long r) {
  if (l == 0) {
    hash[0] = make_pair(s[0], s[0]);
    l++;
  }
  for (int i = l; i <= r; i++) {
    hash[i].first = (hash[i - 1].first * H % mod + s[i]) % mod;
    hash[i].second = (hash[i - 1].second * H2 % mod2 + s[i]) % mod2;
  }
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  srand(time(NULL));
  while (1) {
    mod = getrand() % 1000000000 + 100000000;
    mod2 = getrand() % 1000000000 + 100000000;
    if (mod % H && mod2 % H2) break;
  }
  beki[0] = beki2[0] = 1;
  for (int i = 1; i < 1000005; i++) {
    beki[i] = (beki[i - 1] * H) % mod;
    beki2[i] = (beki2[i - 1] * H2) % mod2;
  }
  cin >> n;
  string s, ans;
  cin >> ans;
  makeHash(ans, hashA, 0, ans.size() - 1);
  for (int i = 1; i < n; i++) {
    cin >> s;
    makeHash(s, hashS, 0, s.size() - 1);
    long long len = min(ans.size(), s.size());
    pair<long long, long long> h = make_pair(0, 0);
    int mx = 0;
    for (int j = 0; j < len; j++) {
      h.first += ans[ans.size() - 1 - j] * beki[j] % mod, h.first %= mod;
      h.second += ans[ans.size() - 1 - j] * beki2[j] % mod2, h.second %= mod2;
      if (h == hashS[j]) mx = max(mx, j + 1);
    }
    ans += s.substr(mx);
    makeHash(ans, hashA, ans.size() - (s.size() - mx), ans.size() - 1);
  }
  cout << ans << endl;
  return 0;
}
