#include <bits/stdc++.h>
using namespace std;
const int N = 1E6 + 7;
char a[N], b[N];
int nt[N], e;
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    scanf("%s", a);
    int len = strlen(a), i = 0, j = -1;
    nt[0] = -1;
    while (i < len) {
      if (j == -1 || a[i] == a[j])
        nt[++i] = ++j;
      else
        j = nt[j];
    }
    i = max(0, e - len), j = 0;
    while (i < e) {
      if (j == -1 || a[j] == b[i])
        i++, j++;
      else
        j = nt[j];
    }
    while (j < len) {
      b[e] = a[j];
      putchar(b[e]);
      e++, j++;
    }
  }
}
