#include <bits/stdc++.h>
using namespace std;
time_t seed_obj;
mt19937 engine_obj;
uniform_int_distribution<int> distribution_obj;
const int nn = 1e6 + 7;
int base[10] = {197, 157, 667, 377, 493, 551, 841, 437, 247, 319};
int mod[10] = {1671264299, 1271268137, 1471238341, 1071236003, 1111114027,
               2000003209, 1000001311, 1000004519, 1990002397, 1790000981};
int base_power[10][nn + 1];
int hash_original[10][nn + 1];
int max_value = 1.5e8;
inline int original_substring_hash(int l, int r, int type) {
  return (mod[type] + 1ll * hash_original[type][r + 1] -
          (hash_original[type][l] * 1ll * base_power[type][r - (l - 1)]) %
              mod[type]) %
         mod[type];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  seed_obj = chrono::high_resolution_clock::now().time_since_epoch().count();
  engine_obj = mt19937(seed_obj);
  distribution_obj = uniform_int_distribution<int>(200, max_value);
  for (int i = 0; i < 10; ++i) {
    int random_base = distribution_obj(engine_obj);
    base[i] = random_base;
  }
  for (int i = 0; i < 10; ++i) {
    base_power[i][0] = 1;
    for (int j = 1; j < nn; ++j) {
      base_power[i][j] = (base_power[i][j - 1] * 1ll * base[i]) % mod[i];
    }
  }
  int total;
  cin >> total;
  total--;
  string s;
  cin >> s;
  int n = s.size();
  string answer = "";
  for (int i = 0; i < 10; ++i) {
    int sum = 0;
    hash_original[i][0] = 0;
    for (int j = 0; j < n; ++j) {
      hash_original[i][j + 1] =
          ((hash_original[i][j] * 1ll * base[i]) % mod[i] + (s[j] - '0' + 1)) %
          mod[i];
    }
  }
  answer += s;
  int cnt = n;
  int pos = -1;
  int second_hash[10] = {0};
  int first_hash;
  while (total--) {
    cin >> s;
    n = s.size();
    bool status = true;
    pos = -1;
    memset(second_hash, 0, sizeof(second_hash));
    for (int j = 0; j < min(n, cnt); ++j) {
      status = true;
      for (int i = 0; i < 10; ++i) {
        second_hash[i] =
            ((second_hash[i] * 1ll * base[i]) % mod[i] + s[j] - '0' + 1) %
            mod[i];
        first_hash = original_substring_hash(cnt - 1 - j, cnt - 1, i);
        if (first_hash != second_hash[i]) {
          status = false;
        }
      }
      if (status == true) pos = j;
    }
    for (int i = pos + 1; i < n; ++i) {
      answer += s[i];
      for (int j = 0; j < 10; ++j) {
        hash_original[j][cnt + 1] =
            ((hash_original[j][cnt] * 1ll * base[j]) % mod[j] + s[i] - '0' +
             1) %
            mod[j];
      }
      cnt++;
    }
  }
  cout << answer << "\n";
  return 0;
}
