#include <bits/stdc++.h>
using namespace std;
int main() {
  map<pair<long long int, long long int>, long long int> m;
  long long int ans = 0;
  long long int n, count = 0;
  cin >> n;
  string s;
  for (int i = 1; i <= n; i++) {
    int l = 0, r = 0;
    cin >> s;
    for (int j = 0; j < s.length(); j++)
      if (s[j] == '(')
        l++;
      else if (s[j] == ')' && l > 0)
        l--;
      else
        r++;
    if (l > 0 && r > 0)
      continue;
    else if (l == 0 && r == 0) {
      ans++;
      continue;
    } else if (l > 0)
      m[make_pair(0, l)]++;
    else
      m[make_pair(1, r)]++;
  }
  ans = ans * ans;
  count = 0;
  for (map<pair<long long int, long long int>, long long int>::iterator it =
           m.begin();
       it != m.end(); it++)
    count = count +
            m[it->first] * m[make_pair(!(it->first.first), it->first.second)];
  cout << ans + count / 2;
  return 0;
}
