#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
string str[300005];
long long n, lcnt[300005], rcnt[300005], cnt;
long long tot = 0;
int main() {
  scanf("%lld", &n);
  cnt = 0;
  for (long long i = 0; i < n; i++) {
    cin >> str[i];
    long long l = 0, r = 0;
    for (long long j = 0; j < str[i].size(); j++) {
      if (str[i][j] == '(')
        l++;
      else {
        r++;
        if (l) {
          l--;
          r--;
        }
      }
    }
    if (l > 0 && r > 0) continue;
    if (l == 0 && r == 0)
      cnt++;
    else if (r == 0)
      lcnt[l]++;
    else
      rcnt[r]++;
  }
  long long ans = cnt * cnt;
  for (long long i = 1; i <= 300000; i++) ans += lcnt[i] * rcnt[i];
  printf("%lld\n", ans);
  return 0;
}
