#include <bits/stdc++.h>
const double pi = 4.0 * atan(1.0);
const double e = exp(1.0);
using namespace std;
string a;
long long l[300100];
long long r[300100];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  long long ll, lr;
  for (long long i = 1; i <= n; i++) {
    cin >> a;
    ll = 0;
    lr = 0;
    for (long long t = 0; t < a.size(); t++) {
      if (a[t] == ')') {
        if (lr == 0) {
          ll++;
        } else {
          lr--;
        }
      }
      if (a[t] == '(') {
        lr++;
      }
    }
    if (lr == 0) l[ll]++;
    if (ll == 0) r[lr]++;
  }
  long long sum = 0;
  for (long long i = 0; i <= 300000; i++) {
    sum += l[i] * r[i];
  }
  cout << sum << endl;
}
