#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int p) {
  long long int r = 1;
  x = x % p;
  while (y) {
    if (y & 1) r = r * x % p;
    y = y >> 1;
    x = x * x % p;
  }
  return r;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l = 0, int r = 1e9) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}
const int N = 3e5 + 99;
long long int pf[N], sf[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int j = 0; j < n; j++) {
    string s;
    cin >> s;
    int ps = 0, l = s.length();
    for (int i = 0; i < l; i++) {
      if (s[i] == '(')
        ps++;
      else
        ps--;
      if (ps < 0) {
        ps = -1e9;
        break;
      }
    }
    if (ps >= 0) pf[ps]++;
    ps = 0;
    for (int i = l - 1; i >= 0; i--) {
      if (s[i] == '(')
        ps--;
      else
        ps++;
      if (ps < 0) {
        ps = -1e9;
        break;
      }
    }
    if (ps >= 0) sf[ps]++;
  }
  long long int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += (pf[i] * sf[i] * 1LL);
  }
  cout << ans << endl;
}
