#include <bits/stdc++.h>
using namespace std;
int fre[600105];
char str[600105];
vector<int> adj[600105];
int n;
int tsum[600105];
int tmn[600105];
inline void proc(int ind) {
  int sum = 0;
  int mn = adj[ind][0];
  for (int i = 0; i < (int)adj[ind].size(); i++) {
    sum += adj[ind][i];
    mn = min(mn, sum);
  }
  tsum[ind] = sum;
  tmn[ind] = mn;
  if (mn >= sum) {
    fre[sum + 300000]++;
  }
}
inline void add(int ind) {
  for (int i = 0; str[i]; i++) {
    if (str[i] == '(') adj[ind].push_back(1);
    if (str[i] == ')') adj[ind].push_back(-1);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", str);
    add(i);
    proc(i);
  }
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    if (tsum[i] >= 0 && tmn[i] >= 0) {
      cnt += (long long)fre[tsum[i] * -1 + 300000];
    }
  }
  printf("%lld\n", cnt);
  return 0;
}
