#include <bits/stdc++.h>
using namespace std;
map<int, int> lhs;
map<int, int> rhs;
string s;
int sgn(int nr) {
  if (nr >= 0) return 1;
  return -1;
}
int par(char c) {
  if (c == '(') return 1;
  return -1;
}
int calc(string s) {
  int i = 0, h = 0;
  while (i < (int)(s).size() && h >= 0) {
    h += par(s[i]);
    i++;
  }
  if (i >= (int)(s).size() && h >= 0) return h;
  return (1 << 30);
}
string rev(string s) {
  reverse(s.begin(), s.end());
  for (int i = 0; i < (int)(s).size(); i++)
    if (s[i] == '(')
      s[i] = ')';
    else
      s[i] = '(';
  return s;
}
int main() {
  int n;
  cin >> n;
  int i, z;
  long long ans = 0, l1, l2;
  for (i = 0; i < n; i++) {
    cin >> s;
    z = calc(s);
    if (z != (1 << 30))
      lhs[z]++;
    else {
      z = calc(rev(s));
      if (z != (1 << 30)) rhs[z]++;
    }
  }
  map<int, int>::iterator itr;
  l1 = lhs[0] + rhs[0];
  ans += 1LL * l1 * (l1 - 1LL) + 1LL * lhs[0] + 1LL * rhs[0];
  for (itr = rhs.begin(); itr != rhs.end(); itr++)
    if ((*itr).first != 0) {
      l1 = lhs[(*itr).first];
      l2 = (*itr).second;
      ans += 1LL * l1 * l2;
      lhs[(*itr).first] = rhs[(*itr).first] = 0;
    }
  cout << ans;
  return 0;
}
