#include <bits/stdc++.h>
using namespace std;
const int N = 3 * 1e6 + 10;
const long long base1 = 191, base2 = 307;
const long long mod1 = 1000001011, mod2 = 1000009999;
long long pow1[N], pow2[N];
long long x, y;
vector<pair<long long, long long> > h;
string ss;
void find_hash(string s) {
  for (char ch : s) {
    x = (x * base1 + ch) % mod1;
    y = (y * base2 + ch) % mod2;
    h.push_back({x, y});
  }
}
void merge_string(string s) {
  long long p = 0LL, q = 0LL;
  int len = 0, pos = 0;
  for (char ch : s) {
    p = (p * base1 + ch) % mod1;
    q = (q * base2 + ch) % mod2;
    int r = ss.size() - 1, l = max(0, r - len);
    long long xx = h[r].first;
    long long yy = h[r].second;
    if (l) {
      xx = (xx - (h[l - 1].first * pow1[r - l + 1]) % mod1 + mod1) % mod1;
      yy = (yy - (h[l - 1].second * pow2[r - l + 1]) % mod2 + mod2) % mod2;
    }
    if (xx == p && yy == q) pos = len + 1;
    len += 1;
  }
  while (pos < s.size()) {
    ss += s[pos];
    char ch = s[pos];
    x = (x * base1 + ch) % mod1;
    y = (y * base2 + ch) % mod2;
    h.push_back({x, y});
    pos += 1;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s1, s2, s3;
  pow1[0] = pow2[0] = 1;
  for (int i = 1; i < N; i++) {
    pow1[i] = (pow1[i - 1] * base1) % mod1;
    pow2[i] = (pow2[i - 1] * base2) % mod2;
  }
  long long n;
  cin >> n;
  cin >> s1;
  x = 0LL, y = 0LL;
  ss = s1;
  find_hash(s1);
  n--;
  while (n--) {
    cin >> s2;
    merge_string(s2);
  }
  cout << ss << endl;
  return 0;
}
