#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1000000007;
long long int MOD1 = 998244353;
mt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());
void solve() {
  int n;
  cin >> n;
  vector<int> l(n), r(n);
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int t = 0;
    for (int j = 0; j < s.size(); j++) {
      if (t == 0 && s[j] == ')') {
        l[i]++;
      } else if (t > 0 && s[j] == ')') {
        t--;
      } else {
        t++;
      }
    }
    r[i] = t;
    if (t == 0) m[l[i]]++;
  }
  long long int c = 0;
  for (int i = 0; i < n; i++) {
    if (l[i] == 0) {
      c += m[r[i]];
    }
  }
  cout << c << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
