#include <bits/stdc++.h>
using namespace std;
bool oneType, open;
long long int cnt;
bool isBalanced(string a) {
  stack<char> s;
  s.push(a[0]);
  bool flag = true;
  for (long long int i = 1; i < a.length(); i++) {
    if (a[i] == '(')
      s.push(a[i]);
    else {
      if (s.size() != 0 && s.top() == '(')
        s.pop();
      else {
        s.push(a[i]);
        flag = false;
      }
    }
  }
  if (s.size() == 0 && flag) return true;
  set<char> s1;
  cnt = s.size();
  while (!s.empty()) {
    s1.insert(s.top());
    s.pop();
  }
  if (s1.size() == 1) {
    oneType = true;
    if (s1.find('(') != s1.end())
      open = true;
    else
      open = false;
  } else
    oneType = false;
  return false;
}
int main() {
  long long int n;
  cin >> n;
  map<long long int, long long int> m1, m2;
  long long int ans = 0;
  long long int a1 = 0;
  string a;
  for (long long int i = 0; i < n; i++) {
    cin >> a;
    if (isBalanced(a))
      a1++;
    else {
      if (oneType) {
        if (open)
          m1[cnt]++;
        else
          m2[cnt]++;
      }
    }
  }
  ans = a1 * a1;
  map<long long int, long long int>::iterator itr;
  long long int val;
  for (itr = m1.begin(); itr != m1.end(); itr++) {
    val = itr->first;
    ans += itr->second * (m2[val]);
  }
  cout << ans << "\n";
  return 0;
}
