9
lfpgbnlzyn
c
s
w
r
m
q
y
yinfblfcdhidphyfvgkxyuwomahiibbhnigdslsguhjkplibnhhrshtekwgefxeugyyyyy
 6
u
p
m
z
v
vv
 4
qe
nd
iqryhukieskfvaeettersinksrmazelxtgvartuz
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 6
nf
ysvchtjkfgsbyfzxjaykey
advqnf
wl
pi
ppppfvvmaebvhkoagppppp
 3
j
k
kkailgwqnxtdsttkkkkkkk
 4
o
yhnx
e
ennn
 10
j
dyfu
udzj
wwow
xtnw
f
c
q
o
gggg
 6
w
g
c
j
y
f
 4
r
o
w
wwwwwwwwww
 2
zxwp
ppppctfisvflhtjggg
 5
m
g
u
t
tttt
 2
n
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
 3
lt
en
eeeeeeeeee
 4
vr
hp
l
llbn

7 5 541 10 10 4 4 1 21 5 9 93 21 3
#include<bits/stdc++.h>
#define LL long long
#define R register int
using namespace std;
const int N=1e5+9;
string s[N];
inline bool all(const string&s,char c){
	for(auto x:s)if(x!=c)return 0;
	return 1;
}
int main(){
	R n,ans=0;cin>>n;
	for(R i=1;i<=n;++i)cin>>s[i];
	for(char c='a';c<='z';++c){
		R pre=0,suf=0,res=0;
		for(R i=1;i<=n;++i){
			R a=s[i].size();
			if(all(s[i],c)){
				pre+=pre*a+a;
				suf+=suf*a+a;
				res+=res*a+a;
			}
			else{
				pre=0;for(R j=0;s[i][j]==c;++j,++pre);
				suf=0;for(R j=a-1;s[i][j]==c;--j,++suf);
				res=res?pre+suf+1:max(pre,suf);
			}
		}
		ans=max(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}
