#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool uin(T& a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
inline bool uax(T& a, T b) {
  return a < b ? (a = b, true) : false;
}
const int nax = 1e6 + 10;
int pi[nax];
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int N;
  string ans;
  cin >> N >> ans;
  for (int tt = 0; tt < N - 1; ++tt) {
    string cur_word;
    cin >> cur_word;
    int start = max(0, (int)ans.size() - (int)cur_word.size());
    string kmp_str =
        cur_word + '$' +
        ans.substr(start, min((int)ans.size(), (int)cur_word.size()));
    ;
    pi[0] = 0;
    for (int i = 1; i < (int)kmp_str.size(); ++i) {
      int j = pi[i - 1];
      while (j > 0 && kmp_str[i] != kmp_str[j]) j = pi[j - 1];
      pi[i] = j + (int)(kmp_str[i] == kmp_str[j]);
    }
    int overlap = pi[(int)kmp_str.size() - 1];
    ans += cur_word.substr(overlap, (int)cur_word.size() - overlap);
  }
  cout << ans << '\n';
}
