#include <bits/stdc++.h>
int SequenceValue(char seq[], int *min_val) {
  int value = 0;
  *min_val = 0;
  char *it = seq;
  while (*it != '\0' && *it != '\n') {
    value += (*it == '(') ? 1 : -1;
    if (value < *min_val) {
      *min_val = value;
    }
    it += 1;
  }
  return value;
}
char seq[300000 + 5];
int starts[300000];
int ends[300000];
int main() {
  int n;
  scanf("%d%*c", &n);
  long long int pairs = 0;
  int i;
  for (i = 0; i < n; ++i) {
    fgets(seq, 300000 + 1, stdin);
    int min_val;
    int value = SequenceValue(seq, &min_val);
    if (min_val < value && min_val < 0) {
      continue;
    }
    if (value == 0) {
      pairs += 1LL * 2 * starts[0] + 1;
      starts[0] += 1;
      continue;
    }
    if (value > 0) {
      pairs += 1LL * ends[value];
      starts[value] += 1;
    } else {
      pairs += 1LL * starts[-value];
      ends[-value] += 1;
    }
  }
  printf("%I64d\n", pairs);
  return 0;
}
