#include <bits/stdc++.h>
using namespace std;
string a[300005];
int lefts[300005] = {0};
int rights[300005] = {0};
bool vis[300005] = {0};
map<pair<int, int>, int> mp;
int main() {
  int n, j, i;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    int l = 0, r = 0;
    for (j = 0; j < a[i].size(); j++) {
      if (a[i][j] == '(') {
        l++;
      } else if (a[i][j] == ')' && l > 0) {
        l--;
      } else if (a[i][j] == ')' && l == 0) {
        r++;
      }
    }
    lefts[i] = l;
    rights[i] = r;
  }
  for (i = 0; i < n; i++) {
    if (lefts[i] != 0 && rights[i] != 0) {
      vis[i] = true;
    }
  }
  for (i = 0; i < n; i++) {
    if (!vis[i]) {
      mp[make_pair(lefts[i], rights[i])]++;
    }
  }
  long long ans = 0;
  for (i = 0; i < n; i++) {
    if (!vis[i] && rights[i] == 0) {
      ans += (long long)mp[make_pair(0, lefts[i])];
    }
  }
  cout << ans << endl;
  return 0;
}
