#include <bits/stdc++.h>
using namespace std;
const int maxn = 300010;
long long ans;
int n, t[maxn << 1], vis[maxn];
char s[maxn];
inline int max(int x, int y) { return x > y ? x : y; }
void dec(int dfn) {
  int len = strlen(s), cnt, lc = 0, rc = 0;
  register int l = 0, r = 0;
  while (s[l] != '(' && l < len) l++;
  while (l < len) {
    r = max(r, l + 1);
    while (s[r] != ')' && r < len) r++;
    if (r < len) {
      cnt++;
      vis[l] = vis[r] = dfn;
    }
    l++;
    r++;
    while (s[l] != '(' && l < len) l++;
  }
  for (register int i = 0; i < len; i++)
    if (vis[i] != dfn) {
      if (s[i] == '(')
        lc++;
      else
        rc++;
    }
  if (lc && !rc) t[lc + 300000]++;
  if (rc && !lc) t[300000 - rc]++;
  if (!lc && !rc) t[300000]++;
}
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; i++) {
    scanf("%s", s);
    dec(i);
  }
  for (register int i = 300000; i <= 600000; i++)
    ans += (long long)t[i] * t[600000 - i];
  printf("%lld\n", ans);
  return 0;
}
