#include <bits/stdc++.h>
using namespace std;
long long l[312345];
long long r[312345];
int32_t main() {
  long long ans = 0;
  long long correct = 0;
  for (long long i = 0; i < 312345; i++) l[i] = r[i] = 0;
  long long n;
  cin >> n;
  while (n--) {
    string s;
    cin >> s;
    long long open = 0;
    for (char c : s) {
      if (c == ')')
        open--;
      else
        open++;
      if (open < 0) break;
    }
    if (open == 0) correct++;
    if (open > 0) l[open]++;
    for (char& c : s) {
      if (c == '(')
        c = ')';
      else
        c = '(';
    }
    reverse(s.begin(), s.end());
    open = 0;
    for (char c : s) {
      if (c == ')')
        open--;
      else
        open++;
      if (open < 0) break;
    }
    if (open > 0) r[open]++;
  }
  ans += correct * correct;
  for (long long i = 0; i < 312345; i++) ans += l[i] * r[i];
  cout << ans << endl;
}
