#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e6 + 131;
const int INF = 1e9 + 7;
const int base = 1e9;
const int MAX = 1e6 + 131;
const double EPS = 1e-9;
const double PI = acos(-1.);
int main() {
  int n;
  long long cnt0 = 0;
  long long res = 0;
  cin >> n;
  vector<string> v(n);
  map<int, int> op, cl;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    int o = 0, c = 0;
    for (int j = 0; j < v[i].size(); j++) {
      if (v[i][j] == '(')
        o++;
      else
        o = max(0, o - 1);
    }
    for (int j = v[i].size() - 1; j >= 0; j--) {
      if (v[i][j] == ')')
        c++;
      else
        c = max(0, c - 1);
    }
    if (c * o != 0) continue;
    if (c == 0 && o == 0) {
      cnt0++;
      continue;
    }
    if (o == 0) {
      if (cl[c]) {
        res += cl[c];
      }
      op[c]++;
    }
    if (c == 0) {
      if (op[o]) {
        res += op[o];
      }
      cl[o]++;
    }
  }
  cout << res + cnt0 * cnt0;
  return 0;
}
