#include <bits/stdc++.h>
using namespace std;
long long correct = 0;
long long ans = 0;
vector<long long> nLeft(300005);
vector<long long> nRight(300005, 0);
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    stack<char> r;
    stack<char> l;
    string s;
    cin >> s;
    for (int i = s.size() - 1; i >= 0; i--) {
      if (s[i] == ')') {
        l.push(s[i]);
      } else {
        if (l.size())
          l.pop();
        else
          r.push(s[i]);
      }
    }
    if (!l.size() && !r.size())
      correct++;
    else if (!l.size())
      nRight[r.size()]++;
    else if (!r.size())
      nLeft[l.size()]++;
  }
  ans = correct * (correct - 1) + correct;
  for (int i = 0; i < 300005; i++) ans += nLeft[i] * nRight[i];
  cout << ans;
  return 0;
}
