#include <bits/stdc++.h>
const int maxx = 1e6 + 100;
const double eps = 1e-10;
const int mod = 10007;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
long long n, m, T;
long long l, r;
long long ans;
string s, t;
stack<char> q;
map<int, long long> p;
map<int, long long>::iterator it;
int main() {
  int i, j, k, len;
  while (scanf("%d", &n) == 1) {
    getchar();
    p.clear();
    m = ans = 0;
    for (i = 0; i < n; i++) {
      cin >> s;
      len = s.size();
      while (!q.empty()) q.pop();
      for (j = 0; j < len; j++) {
        if (q.size() == 0)
          q.push(s[j]);
        else {
          if (q.top() == '(' && s[j] == ')')
            q.pop();
          else
            q.push(s[j]);
        }
      }
      char now = '#';
      bool ok = true;
      int cnt = 0;
      if (!q.empty()) {
        now = q.top();
        q.pop();
        cnt++;
      } else
        ans++;
      while (!q.empty()) {
        if (q.top() == now) {
          cnt++;
          q.pop();
        } else {
          ok = false;
          break;
        }
      }
      if (ok) {
        if (now == '(') {
          p[cnt] += 1;
        } else if (now == ')') {
          p[-cnt] += 1;
        }
      }
    }
    for (it = p.begin(); it != p.end(); it++) {
      k = it->first;
      k = -k;
      if (p[-k] && p[k]) {
        m += p[k] * p[-k];
        p[k] = p[-k] = 0;
      }
    }
    ans = ans * (ans - 1) + ans + m;
    cout << ans << endl;
  }
  return 0;
}
