#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 5;
const long long base = 90000049;
const int oo = 0x7fffffff;
const int sup = 0x80000000;
template <typename it>
void db(it *begin, it *end) {
  while (begin != end) cout << (*begin++) << " ";
  puts("");
}
template <typename it>
string to_str(it n) {
  string s = "";
  while (n) s += n % 10 + '0', n /= 10;
  reverse(s.begin(), s.end());
  return s;
}
template <typename it>
int o(it a) {
  cout << a << endl;
  return 0;
}
long long mul(long long a, long long b, long long c) {
  long long ans = 0;
  for (; b; b >>= 1, a = (a + a) % c)
    if (b & 1) ans = (ans + a) % c;
  return ans;
}
long long ksm(long long a, long long b, long long c) {
  long long ans = 1;
  for (; b; b >>= 1, a = mul(a, a, c))
    if (b & 1) ans = mul(ans, a, c);
  return ans;
}
long long hash1[3][N] = {0};
long long hash2[3][N] = {0};
long long b[3][N];
int lena, lenb;
long long mod[3] = {1000000007, 1000000009, 998244353};
char s[N], str[N];
int id(char c) { return c - 48; }
long long f_1(int i, int l, int r) {
  return (hash1[i][r] - hash1[i][l - 1] * b[i][r - l + 1] % mod[i] + mod[i]) %
         mod[i];
}
long long f_2(int i, int l, int r) {
  return (hash2[i][r] - hash2[i][l - 1] * b[i][r - l + 1] % mod[i] + mod[i]) %
         mod[i];
}
int HASH() {
  int len = 0;
  for (int i = 1, j = lena; i <= lenb && j >= 1; i++, j--) {
    int ans = 0;
    for (int k = 0; k < 3; k++) {
      if (f_1(k, j, lena) == f_2(k, 1, i)) ans++;
    }
    if (ans == 3) len = i;
  }
  return len;
}
int main() {
  b[0][0] = b[1][0] = b[2][0] = 1;
  for (int i = 0; i < 3; i++)
    for (int j = 1; j < N; j++) b[i][j] = b[i][j - 1] * base % mod[i];
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    if (i == 1) {
      scanf("%s", str + 1);
      lena = strlen(str + 1);
      for (int k = 0; k < 3; k++)
        for (int j = 1; str[j]; j++) {
          hash1[k][j] = (hash1[k][j - 1] * base % mod[k] + id(str[j])) % mod[k];
        }
    } else {
      scanf("%s", s + 1);
      for (int k = 0; k < 3; k++)
        for (int j = 1; s[j]; j++) {
          hash2[k][j] = (hash2[k][j - 1] * base % mod[k] + id(s[j])) % mod[k];
        }
      lenb = strlen(s + 1);
      strlen(str + 1);
      int len = HASH();
      int x = lena;
      for (int k = len + 1; k <= lenb; k++) str[++lena] = s[k];
      str[lena + 1] = '\0';
      for (int k = 0; k < 3; k++)
        for (int j = x + 1; j <= lena; j++) {
          hash1[k][j] = (hash1[k][j - 1] * base % mod[k] + id(str[j])) % mod[k];
        }
    }
  }
  o(str + 1);
}
