#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
map<int, long long> mp;
int main() {
  int n;
  scanf("%d", &n);
  int cnt;
  string s;
  for (int i = 1; i <= n; ++i) {
    cin >> s;
    cnt = 0;
    int len = s.size();
    int l, r;
    l = r = 0;
    for (int j = 0; j < s.size(); ++j) {
      if (s[j] == '(')
        l++;
      else {
        if (l)
          l--;
        else
          r++;
      }
    }
    if (l == r && r == 0)
      mp[0]++;
    else if (l == 0 && r != 0)
      mp[-r]++;
    else if (r == 0 && l != 0)
      mp[l]++;
  }
  map<int, long long>::iterator it;
  long long ans = 0;
  for (it = mp.begin(); it != mp.end(); ++it) {
    if (it->first <= 0) continue;
    int fi = it->first;
    int se = -fi;
    ans += (it->second) * 1LL * mp[se];
  }
  ans += mp[0] * 1LL * mp[0];
  printf("%lld\n", ans);
  return 0;
}
