#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct by_length {
bool operator() (const string& a, const string& b) const {
if (a.size() != b.size()) {
return a.size() < b.size();
}
return a < b;
}
};
int n;
multiset<string, by_length> secik;
map<string, int> cnt;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
secik.insert(s);
cnt[s]++;
}
int ans = 0;
while (!secik.empty()) {
string shortest = *secik.begin();
secik.erase(secik.begin());
ans = max(ans, (int)shortest.size());
if (cnt[shortest] > 1) {
string new_string = shortest + shortest;
cnt[shortest] -= 2;
secik.erase(secik.find(shortest));
secik.insert(new_string);
cnt[new_string]++;
}
}
cout << ans;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKCnN0cnVjdCBieV9sZW5ndGggewogICAgYm9vbCBvcGVyYXRvcigpIChjb25zdCBzdHJpbmcmIGEsIGNvbnN0IHN0cmluZyYgYikgY29uc3QgewogICAgICAgIGlmIChhLnNpemUoKSAhPSBiLnNpemUoKSkgewogICAgICAgICAgICByZXR1cm4gYS5zaXplKCkgPCBiLnNpemUoKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGEgPCBiOwogICAgfQp9OwoKaW50IG47Cm11bHRpc2V0PHN0cmluZywgYnlfbGVuZ3RoPiBzZWNpazsKbWFwPHN0cmluZywgaW50PiBjbnQ7CgppbnQgbWFpbigpIHsKCiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwogICAgY2luLnRpZSgwKTsKICAgIGNvdXQudGllKDApOwoKICAgIGNpbiA+PiBuOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICBzdHJpbmcgczsKICAgICAgICBjaW4gPj4gczsKCiAgICAgICAgc2VjaWsuaW5zZXJ0KHMpOwogICAgICAgIGNudFtzXSsrOwogICAgfQoKICAgIGludCBhbnMgPSAwOwoKICAgIHdoaWxlICghc2VjaWsuZW1wdHkoKSkgewogICAgICAgIHN0cmluZyBzaG9ydGVzdCA9ICpzZWNpay5iZWdpbigpOwogICAgICAgIHNlY2lrLmVyYXNlKHNlY2lrLmJlZ2luKCkpOwogICAgICAgIGFucyA9IG1heChhbnMsIChpbnQpc2hvcnRlc3Quc2l6ZSgpKTsKCiAgICAgICAgaWYgKGNudFtzaG9ydGVzdF0gPiAxKSB7CiAgICAgICAgICAgIHN0cmluZyBuZXdfc3RyaW5nID0gc2hvcnRlc3QgKyBzaG9ydGVzdDsKCiAgICAgICAgICAgIGNudFtzaG9ydGVzdF0gLT0gMjsKICAgICAgICAgICAgc2VjaWsuZXJhc2Uoc2VjaWsuZmluZChzaG9ydGVzdCkpOwoKICAgICAgICAgICAgc2VjaWsuaW5zZXJ0KG5ld19zdHJpbmcpOwogICAgICAgICAgICBjbnRbbmV3X3N0cmluZ10rKzsKICAgICAgICB9CiAgICB9CgogICAgY291dCA8PCBhbnM7CgogICAgcmV0dXJuIDA7Cn0K