#include <bits/stdc++.h>
using namespace std;
struct Hash1 {
  long long SEED = 1331;
  long long MOD = 1000000007;
  vector<long long> ha;
  vector<long long> power;
  Hash1(string x) {
    ha = vector<long long>(x.size());
    power = vector<long long>(x.size());
    build(x);
  }
  void build(string x) {
    power[0] = 1;
    for (int i = 1; i < (int)power.size(); i++)
      power[i] = (power[i - 1] * SEED) % MOD;
    ha[0] = x[0];
    for (int i = 1; i < (int)ha.size(); i++)
      ha[i] = (ha[i - 1] * SEED + x[i]) % MOD;
  }
  void Add(string x) {
    for (int i = 0; i < x.size(); i++)
      power.push_back((power.back() * SEED) % MOD);
    for (int i = 0; i < x.size(); i++)
      ha.push_back((ha.back() * SEED + x[i]) % MOD);
  }
  long long get(int i, int j) {
    long long ret = ha[j];
    if (i) ret -= ha[i - 1] * power[j - i + 1];
    ret = (ret % MOD + MOD) % MOD;
    return ret;
  }
};
struct Hash2 {
  long long SEED = 1333;
  long long MOD = 1000000009;
  vector<long long> ha;
  vector<long long> power;
  Hash2(string x) {
    ha = vector<long long>(x.size());
    power = vector<long long>(x.size());
    build(x);
  }
  void build(string x) {
    power[0] = 1;
    for (int i = 1; i < (int)power.size(); i++)
      power[i] = (power[i - 1] * SEED) % MOD;
    ha[0] = x[0];
    for (int i = 1; i < (int)ha.size(); i++)
      ha[i] = (ha[i - 1] * SEED + x[i]) % MOD;
  }
  void Add(string x) {
    for (int i = 0; i < x.size(); i++)
      power.push_back((power.back() * SEED) % MOD);
    for (int i = 0; i < x.size(); i++)
      ha.push_back((ha.back() * SEED + x[i]) % MOD);
  }
  long long get(int i, int j) {
    long long ret = ha[j];
    if (i) ret -= ha[i - 1] * power[j - i + 1];
    ret = (ret % MOD + MOD) % MOD;
    return ret;
  }
};
const int N = 1000100;
char buf[N];
string Read() {
  scanf("%s", buf);
  return buf;
}
int main() {
  int n;
  cin >> n;
  string s = Read();
  Hash1 H1(s);
  Hash2 H2(s);
  while (--n) {
    string t = Read();
    Hash1 H3(t);
    Hash2 H4(t);
    int n1 = s.size();
    int n2 = t.size();
    for (int i = min(n1, n2); i; --i) {
      if (H1.get(n1 - i, (n1 - i) + i - 1) == H3.get(0, i - 1) &&
          H2.get(n1 - i, (n1 - i) + i - 1) == H4.get(0, i - 1)) {
        t.erase(0, i);
        break;
      }
    }
    s += t;
    H1.Add(t);
    H2.Add(t);
  }
  cout << s;
}
