#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
char s[1000005];
long long seed = 131;
long long base[1000005][2];
long long MOD[2] = {1000000007, 1000000009};
long long hs[1000005][2];
int tlen, len;
int n;
pair<long long, long long> get(int l, int r) {
  static long long t[2];
  for (int j = (0); j < (int)(2); j++)
    t[j] = (hs[r][j] - hs[l - 1][j] * base[r - l + 1][j] % MOD[j] + MOD[j]) %
           MOD[j];
  return pair<long long, long long>(t[0], t[1]);
}
int findi() {
  int ans = 0;
  for (int t = 1; t <= tlen && t <= len; t++)
    if (get(len - t + 1, len) == get(len + 1, len + t)) ans = t;
  return ans;
}
void has(int tlen) {
  for (int i = 0; i < tlen; i++)
    for (int j = (0); j < (int)(2); j++)
      hs[len + 1 + i][j] = (hs[len + i][j] * seed + s[len + 1 + i]) % MOD[j];
}
void init() {}
int main() {
  cin >> n;
  base[0][0] = base[0][1] = 1;
  for (int i = (1); i <= (int)(1000003); i++)
    for (int j = (0); j < (int)(2); j++)
      base[i][j] = base[i - 1][j] * seed % MOD[j];
  for (int i = (1); i <= (int)(n); i++) {
    scanf("%s", s + 1 + len);
    tlen = strlen(s + len + 1);
    has(tlen);
    int same = findi();
    for (int i = same, j = 0; i < tlen; i++, j++)
      s[1 + len + j] = s[1 + len + i];
    has(tlen - same);
    len += tlen - same;
  }
  s[len + 1] = 0;
  printf("%s", s + 1);
  return 0;
}
