#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int(i)=0 ; (i)<(int)(n) ; ++(i))
#define replu(i,l,u) for(int(i)=(int)(l) ; (i)<=(int)(u) ; ++(i))
#define repul(i,u,l) for(int(i)=(int)(u) ; (i)>=(int)(l) ; --(i))
#define fi first
#define se second
#define pb push_back
typedef vector<int> vi ;
typedef vector<vector<int> > vvi ;
typedef pair<int,int> pii ;
typedef pair<int, pii> pipii ;
typedef vector<pair<int,int> > vpii ;
typedef long long ll ;
const int mod=1e9+7 ;
const ll inf=2e9+10 ;
template <typename T1, typename T2> static void relax(T1 &x, T2 y) { if(x>y) x = y ; }
template <typename T1, typename T2> static void gain(T1 &x, T2 y) { if(x<y) x = y ; }
ll powmod(ll a, ll b) { ll res = 1 ; while(b) { if(b&1) res = (res*a)%mod ; a = (a*a)%mod ; b >>= 1 ; } return res ; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a ; }
const int maxn = 3e5 + 5 ;
int n ;
string a[maxn] ;
pii f[maxn] ;
int main() {
ios::sync_with_stdio(false) ;
cin.tie(NULL) ;
cin >> n ;
rep(i,n) cin >> a[i] ;
int op, cl ;
rep(i,n) {
op = cl = 0 ;
int l = (int)a[i].length() ;
rep(j,l) {
if(a[i][j] == '(') op++ ;
else { if(op > 0) op-- ; else cl++ ; }
}
f[i] = {op, cl} ;
}
int cntop[maxn], cntcl[op] ;
rep(i,maxn) cntop[i] = cntcl[i] = 0 ;
ll ans = 0 ;
rep(i,n) if(f[i].fi == 0 && f[i].se == 0) ans++ ;
ans = ans*ans ;
rep(i,n) {
if(f[i].se == 0 && f[i].fi != 0) {
ans += cntcl[f[i].fi]*1LL ; cntop[f[i].fi]++ ;
}
if(f[i].fi == 0 && f[i].se != 0) {
ans += cntop[f[i].se]*1LL ; cntcl[f[i].se]++ ;
}
}
cout << ans << "\n" ;
return 0 ;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7C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