#include <bits/stdc++.h>
using namespace std;
int main() {
  const int N = 3e5 + 10;
  int arr[N], l[N], r[N];
  int n;
  cin >> n;
  long long int res = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int bal = 0, ok = 1;
    for (int j = 0; j < s.length(); j++) {
      if (s[j] == '(')
        bal++;
      else
        bal--;
      if (bal < 0) ok = 0;
    }
    if (ok) ++l[bal];
    bal = 0;
    ok = 1;
    for (int j = s.length() - 1; j >= 0; j--) {
      if (s[j] == ')')
        bal++;
      else
        bal--;
      if (bal < 0) ok = 0;
    }
    if (ok) ++r[bal];
  }
  for (int i = 0; i < N; i++) res += (long long int)l[i] * r[i];
  cout << res;
  return 0;
}
