#include <bits/stdc++.h>
using namespace std;
struct shash {
  string s;
  vector<long long> h[2];
  long long m[2] = {1000000007, 1000000009};
  long long p[2] = {257, 373};
  static long long pw[2][1000005];
  static bool precomp;
  shash() {}
  shash(string s) {
    if (!precomp) {
      doprecomp();
    }
    append(s);
  }
  void append(char a) {
    s += a;
    for (int i = 0; i < 2; i++) {
      int j = s.size() - 1;
      h[i].emplace_back(0);
      h[i][j] = ((j == 0 ? 0 : h[i][j - 1]) + pw[i][j] * s[j]) % m[i];
    }
  }
  void append(string a) {
    for (int i = 0; i < a.size(); i++) {
      append(a[i]);
    }
  }
  pair<long long, long long> getHash(int l, int r) {
    pair<long long, long long> res = make_pair(0, 0);
    for (int i = 0; i < 2; i++) {
      long long diff = (h[i][r] - (l == 0 ? 0 : h[i][l - 1]) + m[i]) % m[i];
      diff = diff * pw[i][1000005 - l - 1] % m[i];
      if (i == 0)
        res.first = diff;
      else
        res.second = diff;
    }
    return res;
  }
  void doprecomp() {
    precomp = 1;
    for (int i = 0; i < 2; i++) {
      pw[i][0] = 1;
      for (int j = 1; j < 1000005; j++) {
        pw[i][j] = pw[i][j - 1] * p[i] % m[i];
      }
    }
  }
};
bool shash::precomp;
long long shash::pw[2][1000005];
int n;
string s[100005];
shash sh[100005];
shash cur;
string ans;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    char temp[1000005];
    scanf(" %s", &temp);
    s[i] = temp;
  }
  for (int i = 0; i < n; i++) {
    sh[i] = shash(s[i]);
  }
  ans = s[0];
  cur.append(s[0]);
  for (int i = 1; i < n; i++) {
    int hi = min(s[i].size(), ans.size()) - 1;
    int prv = -1;
    for (int j = hi; j >= 0; j--) {
      bool same = sh[i].getHash(0, j) ==
                  cur.getHash(ans.size() - j - 1, ans.size() - 1);
      if (same) {
        prv = j;
        break;
      }
    }
    for (int j = prv + 1; j < s[i].size(); j++) {
      ans += s[i][j];
      cur.append(s[i][j]);
    }
  }
  printf("%s\n", ans.c_str());
  return 0;
}
