#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
const long long INF = 1e9 + 7;
long long n, ns[N], p[N], b[N];
vector<long long> h[N], h1[N];
string s[N];
inline long long Hash(const long long &i, const long long &l,
                      const long long &r) {
  return h[i][r] - h[i][l - 1] * p[r - l + 1];
}
inline long long Hash1(const long long &i, const long long &l,
                       const long long &r) {
  return h1[i][l] - h1[i][r + 1] * p[r - l + 1];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> s[i];
    ns[i] = s[i].size();
    s[i] = "~" + s[i];
    h[i].resize(ns[i] + 3);
    h1[i].resize(ns[i] + 3);
  }
  p[0] = 1;
  for (long long i = 1; i <= 1e6; i++) p[i] = p[i - 1] * 26;
  for (long long i = 1; i <= n; i++) {
    h[i][0] = 0;
    for (long long j = 1; j <= ns[i]; j++) h[i][j] = h[i][j - 1] * 26 + s[i][j];
    h1[i][ns[i] + 1] = 0;
    for (long long j = ns[i]; j >= 1; j--)
      h1[i][j] = h1[i][j + 1] * 26 + s[i][j];
  }
  string res = "";
  for (long long i = 1; i <= ns[1]; i++) res += s[1][i];
  long long c = res.size();
  for (long long i = 1; i <= n; i++) s[i].erase(s[i].begin());
  for (long long i = 2; i <= n; i++) {
    long long l = 0, r = min(ns[i], ns[i - 1]), k = 0;
    while (l == r) {
      long long m = (l + r) >> 1;
      if (Hash1(i - 1, ns[i - 1] - m + 1, ns[i - 1]) == Hash(i, 1, m))
        k = m, l = m + 1;
      else
        r = m - 1;
    }
    for (long long j = k + 1; j <= ns[i]; j++) res += "";
  }
  for (long long i = 0; i < n; i++) s[i] = s[i + 1];
  for (long long j = 1; j < n; j++) {
    long long m = s[j].size();
    long long k = 0;
    b[0] = 0;
    for (long long i = 1; i < min(m, c); i++) {
      while (k && res[c - k - 1] != res[c - i - 1]) k = b[k];
      if (res[c - k - 1] == res[c - i - 1]) ++k;
      b[i + 1] = k;
    }
    k = 0;
    for (long long i = m - 1; i >= 0; i--) {
      if (k == c) k = b[k];
      while (k && res[c - k - 1] != s[j][i]) k = b[k];
      if (res[c - k - 1] == s[j][i]) ++k;
    }
    for (long long i = k; i < m; i++) res.push_back(s[j][i]);
    c = res.size();
  }
  cout << res;
  return 0;
}
