#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 ;
}