#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  unordered_map<long long int, vector<long long int> > mymap;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    long long int a1 = 0, a2 = INT_MAX;
    for (int j = 0; j < s.size(); ++j) {
      if (s[j] == '(')
        a1++;
      else if (s[j] == ')')
        a1--;
      a2 = min(a2, a1);
    }
    if (a1 >= 0 && a2 < 0)
      ;
    else
      mymap[a1].push_back(a2);
  }
  long long int res = 0;
  for (auto it : mymap) {
    if (it.first < 0) continue;
    long long int yy = it.second.size();
    if (mymap.find(-it.first) == mymap.end()) continue;
    vector<long long int> temp = mymap[-it.first];
    for (int i = 0; i < temp.size(); ++i) {
      if (temp[i] + it.first >= 0) res += yy;
    }
  }
  cout << res << "\n";
  return 0;
}
