#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long max_n = 1e5 + 5;
const long long log_n = 20;
const long long inf = 1e9;
const long double pi = acos(-1);
long long pref_back(string &s) {
  long long n = s.size();
  vector<long long> pref(n);
  pref[0] = 0;
  for (long long i = 1; i < n; ++i) {
    long long j = pref[i - 1];
    while (j > 0 && s[i] != s[j]) {
      j = pref[j - 1];
    }
    if (s[i] == s[j]) j++;
    pref[i] = j;
  }
  return pref.back();
}
void run() {
  long long n;
  cin >> n;
  string cur = "";
  for (long long i = 0; i < n; ++i) {
    string s;
    cin >> s;
    long long len = s.size();
    s += '#';
    for (long long j = min((long long)cur.size() - 1, len + 5); j >= 0; --j) {
      s += cur[cur.size() - j - 1];
    }
    long long last = pref_back(s);
    for (long long j = last; j < len; ++j) {
      cur += s[j];
    }
  }
  cout << cur;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) run();
  return 0;
}
