#include <bits/stdc++.h>
char s[300002];
int temp[300002], left[300002], right[300002];
int lmax = 0, rmax = 0;
void deal(char *s) {
  int slen = strlen(s + 1);
  for (int i = 1; i <= slen; i++) {
    if (s[i] == '(')
      temp[i] = -1;
    else
      temp[i] = 1;
  }
  int sum1 = 0, flag = 0;
  for (int i = 1; i <= slen; i++) {
    sum1 += temp[i];
    if (sum1 > 0) {
      flag = i;
      int sum2 = 0;
      for (int j = slen; j > i; j--) {
        sum2 += temp[j];
        if (sum2 < 0) {
          return;
        }
      }
      right[sum1 + sum2]++;
      if (sum1 + sum2 > rmax) rmax = sum1 + sum2;
      return;
    }
  }
  if (sum1) {
    left[-sum1]++;
    if (-sum1 > lmax) lmax = -sum1;
  } else {
    left[0]++;
    right[0]++;
  }
}
long long calans() {
  int max = lmax > rmax ? lmax : rmax;
  long long ans = 0;
  for (int i = 0; i <= max; i++) ans += (long long)left[i] * right[i];
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  memset(left, 0, sizeof(left));
  memset(right, 0, sizeof(right));
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    deal(s);
  }
  printf("%lld\n", calans());
  return 0;
}
