#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 2;
const long long N1 = 1e2 + 2;
const long long mod = 1e9 + 7;
const int MASK = 1 << 17 + 1;
const int who = 6 * N * log2(N);
long long power(long long a, long long b, long long c) {
  long long ret = 1;
  while (b) {
    if (b % 2 == 1) {
      ret = (ret * a) % c;
    }
    b /= 2;
    a = (a * a) % c;
  }
  return ret;
}
pair<int, int> a[N + 2];
map<pair<int, int>, long long> ma, ma1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int len = s.size();
    int plus = 0, minus = 0;
    for (int j = 0; j < len; j++) {
      if (s[j] == '(') {
        plus++;
      } else if (s[j] == ')') {
        if (plus == 0) {
          minus++;
        } else {
          plus--;
        }
      }
    }
    a[i] = make_pair(plus, minus);
    if (min(plus, minus) == 0) {
      ma[a[i]]++;
    }
  }
  long long tm1 = ma[make_pair(0, 0)];
  long long ans = tm1 * tm1;
  ma1[make_pair(0, 0)] = 1;
  for (int i = 0; i < n; i++) {
    int plus = a[i].first, minus = a[i].second;
    if (min(plus, minus) > 0 || ma1[a[i]] > 0) {
      continue;
    }
    ma1[a[i]]++;
    ma1[make_pair(minus, plus)]++;
    ans += ma[a[i]] * ma[make_pair(minus, plus)];
  }
  cout << ans << "\n";
}
