#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long mod = (1e9) + 7;
map<int, long long int> mpre;
map<int, long long int> mpost;
int main() {
  long long int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    string x;
    cin >> x;
    s[i] = x;
    int cnt = 0;
    int l = x.length();
    int pre = 0, post = 0;
    for (int i = 0; i < l; i++) {
      cnt += x[i] == '(' ? 1 : -1;
      if (cnt < 0) pre = max(pre, abs(cnt));
    }
    post = cnt;
    if (pre == 0 && cnt == 0) {
      mpre[0]++;
      mpost[0]++;
      continue;
    }
    if (cnt != -1 * pre && pre) continue;
    if (cnt > 0 && pre) continue;
    if (pre > 0) mpre[pre]++;
    if (post > 0) mpost[post]++;
  }
  long long int ans = 0;
  for (auto it : mpre) {
    ans += it.second * mpost[it.first];
  }
  cout << ans;
  return 0;
}
