#include #define ALL(v) std::begin(v),std::end(v) using lint=long long; using ld=long double; void cmn(lint&x,lint y){if(x>y)x=y;} int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::cout.setf(std::ios_base::fixed);std::cout.precision(15); lint n;std::cin>>n; std::vectors(n); for(auto&&t:s)std::cin>>t; std::vector>a(n); for(lint i=n-1;i>=0;i--){ auto&&now=a.at(i); a.at(i).resize(s.at(i).length(),1); if(i==n-1)continue; auto&next=a.at(i+1); for(lint j=0;j<(lint)std::min(now.size(),next.size());j++){ if(s.at(i).at(j)!=s.at(i+1).at(j))continue; now.at(j)=next.at(j)+1; if(j)cmn(now.at(j),now.at(j-1)); } } auto comb=[&](lint n){return n*(n+1)*(n+2)/6;}; lint ans=0; for(lint i=0;i