#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
T power(T b, U n) {
  assert(n >= 0);
  T ans = 1;
  for (; n > 0; n /= 2, b *= b)
    if (n & 1) ans *= b;
  return ans;
}
long long power(long long b, long long n, long long mod) {
  assert(n >= 0);
  long long ans = 1;
  for (; n > 0; n /= 2, b = (b * b) % mod)
    if (n & 1) ans = (ans * b) % mod;
  return ans;
}
template <long long mod>
struct Modular {
  long long val;
  Modular() {}
  Modular(long long _val) { val = _val; }
  Modular normalize(const long long x) {
    val = x % mod;
    if (val < 0) val += mod;
    return val;
  }
  bool operator==(const Modular &a) { return val == a.val; }
  bool operator!=(const Modular &a) { return val != a.val; }
  Modular operator=(long long x) { return normalize(x); }
  Modular operator=(const Modular &x) {
    val = x.val;
    return *this;
  }
  Modular operator+=(const Modular &a) { return normalize(val + a.val); }
  Modular operator-=(const Modular &a) { return normalize(val - a.val); }
  Modular operator*=(const Modular &a) { return normalize(val * a.val); }
  Modular operator/=(const Modular &b) {
    return normalize(val * inverse(b).val);
  }
  friend Modular operator^(Modular b, long long n) { return power(b, n); }
  friend Modular inverse(Modular b) { return b ^ (mod - 2); }
  friend Modular operator+(Modular a, const Modular &b) { return a += b; }
  friend Modular operator-(Modular a, const Modular &b) { return a -= b; }
  friend Modular operator*(Modular a, const Modular &b) { return a *= b; }
  friend Modular operator/(Modular a, const Modular &b) { return a /= b; }
  friend Modular operator+(Modular a, long long b) { return a += b; }
  friend Modular operator-(Modular a, long long b) { return a -= b; }
  friend Modular operator*(Modular a, long long b) { return a *= b; }
  friend Modular operator/(Modular a, long long b) { return a /= b; }
  friend Modular operator+(long long b, Modular a) { return a += b; };
  friend Modular operator-(long long b, const Modular &a) {
    Modular c(b);
    return c -= a;
  }
  friend Modular operator*(long long b, Modular a) { return a *= b; };
  friend Modular operator/(long long b, const Modular &a) {
    Modular c(b);
    return c /= a;
  }
  friend istream &operator>>(istream &in, Modular &a) {
    long long x;
    in >> x;
    a.normalize(x);
    return in;
  }
  friend ostream &operator<<(ostream &out, const Modular &a) {
    return out << a.val;
  }
};
const int mx = 1e6 + 5;
const long long mod1 = 998244353;
const long long mod2 = 1e9 + 7;
void solve() {
  int n;
  cin >> n;
  vector<string> vec(n);
  for (string &x : vec) cin >> x;
  vector<Modular<mod1> > pwr1(mx + 1, 1);
  for (int i = 1; i <= mx; i++) pwr1[i] = pwr1[i - 1] * 31;
  vector<Modular<mod2> > pwr2(mx + 1, 1);
  for (int i = 1; i <= mx; i++) pwr2[i] = pwr2[i - 1] * 29;
  vector<Modular<mod1> > pref1(1, 0);
  vector<Modular<mod2> > pref2(1, 0);
  string ans = vec[0];
  int sz = ans.size();
  int p = mx;
  for (int i = 0; i < sz; i++, p--) {
    pref1.push_back(pref1.back() + pwr1[p] * ans[i]);
    pref2.push_back(pref2.back() + pwr2[p] * ans[i]);
  }
  for (string x : vec) {
    Modular<mod1> curr1 = 0;
    Modular<mod2> curr2 = 0;
    int maxi = -1;
    int limit = min(sz, int(x.size()));
    for (int i = 0, j = mx; i < limit; i++, j--) {
      curr1 += pwr1[j] * x[i];
      curr2 += pwr2[j] * x[i];
      Modular<mod1> temp1 = pref1[sz] - pref1[sz - i - 1];
      temp1 *= pwr1[sz - i - 1];
      Modular<mod2> temp2 = pref2[sz] - pref2[sz - i - 1];
      temp2 *= pwr2[sz - i - 1];
      if (temp1 == curr1 && temp2 == curr2) maxi = i;
    }
    string now = x.substr(maxi + 1);
    ans += now;
    for (int i = 0; i < now.size(); i++, p--) {
      pref1.push_back(pref1.back() + pwr1[p] * now[i]);
      pref2.push_back(pref2.back() + pwr2[p] * now[i]);
      sz++;
    }
  }
  cout << ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int testcase = 1;
  for (int i = 1; i <= testcase; i++) {
    solve();
  }
  return 0;
}
