#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int maxn = 3e5 + 25;
long long n, mx = 0;
char ch[maxn];
map<long long, long long> mp;
int main() {
  cin >> n;
  for (long long j = 0; j < n; j++) {
    scanf("%s", ch);
    long long flag = 0, k = 0, l = strlen(ch);
    for (long long i = 0; i < l; i++) {
      if (ch[i] == '(')
        k++;
      else
        k--;
      if (k < 0) flag = min(k, flag);
    }
    if (flag < 0 && k > flag)
      continue;
    else {
      mp[k]++;
      mx = max(k, mx);
    }
  }
  long long sum = 0;
  for (int i = 0; i <= mx; i++) sum += mp[i] * mp[-i];
  cout << sum << endl;
  return 0;
}
