#include <bits/stdc++.h>
using namespace std;
const int maxm = 300001;
map<int, int> tm;
char str[maxm];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int unleft = 0;
    int unright = 0;
    scanf("%s", str);
    int k = 0;
    int len = strlen(str) - 1;
    while ((int)str[k] != '(' && k <= len) k++;
    unleft = k;
    stack<int> sig;
    for (; k <= len; ++k) {
      if ((int)str[k] == '(') sig.push('(');
      if ((int)str[k] == ')') {
        if (sig.size())
          sig.pop();
        else
          unleft++;
      }
    }
    unright = sig.size();
    if (unleft == 0 && unright == 0) {
      tm[0]++;
      continue;
    }
    if (unleft && unright)
      continue;
    else {
      if (unleft)
        tm[unleft]++;
      else
        tm[-unright]++;
    }
  }
  long long ans = 0;
  for (int i = 0; i <= 300000; ++i) {
    ans += (long long)((long long)tm[i] * (long long)tm[-i]);
  }
  cout << ans;
}
