#include <bits/stdc++.h>
using namespace std;
int n, a[300005], rb[300005], lb[300005], dap;
char s[300005];
void f(int xx) {
  int i, j, x, y, z;
  int sn;
  sn = strlen(s);
  x = y = 0;
  for (i = 0; i < sn; i++) {
    if (s[i] == ')') {
      if (x > 0)
        x--;
      else
        y++;
    } else
      x++;
  }
  if (x == 0 && y == 0) a[xx] = 1000000;
  if (x > 0 && y > 0)
    a[xx] = 500000;
  else if (x > 0)
    a[xx] = x, rb[x]++;
  else if (y > 0)
    a[xx] = -y, lb[y]++;
}
int main() {
  long long i, j, x, y, z;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", s);
    f(i);
  }
  x = 0;
  y = 0;
  for (i = 0; i < n; i++) {
    if (a[i] == 500000) continue;
    if (a[i] == 1000000)
      y++;
    else if (a[i] < 0)
      x += rb[-a[i]];
  }
  x = y * y + x;
  printf("%lld\n", x);
  return 0;
}
