#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  string s;
  map<long long int, long long int> hash;
  for (long long int i = 0; i < n; i++) {
    cin >> s;
    long long int left = 0, right = 0;
    for (char j : s) {
      if (j == '(')
        left++;
      else if (left > 0)
        left--;
    }
    reverse(s.begin(), s.end());
    for (char j : s) {
      if (j == ')')
        right++;
      else if (right > 0)
        right--;
    }
    if (!left)
      hash[-right]++;
    else if (!right)
      hash[left]++;
  }
  long long int ans = 0;
  map<long long int, long long int>::iterator it;
  for (it = hash.begin(); it != hash.end() && ((it->first) <= 0); it++) {
    if (it->first != 0) {
      ans += (it->second) * (hash[-it->first]);
    } else {
      ans += (it->second) * (it->second);
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
