#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  string st[n];
  map<int, int> mp1, mp2;
  for (int i = 0; i < n; ++i) {
    cin >> st[i];
    int cnt = 0, f = 1;
    for (int j = ((int)st[i].length()) - 1; j >= 0; j--) {
      if (st[i][j] == ')')
        cnt++;
      else if (st[i][j] == '(')
        cnt--;
      if (cnt < 0) {
        f = 0;
      }
    }
    if (f) mp1[cnt]++;
    f = 1;
    cnt = 0;
    for (ll j = (0); (1 - 2 * (0 > ((int)st[i].length()) - 1)) > 0
                         ? j <= (((int)st[i].length()) - 1)
                         : j >= (((int)st[i].length()) - 1);
         j += (1 - 2 * (0 > ((int)st[i].length()) - 1))) {
      if (st[i][j] == ')')
        cnt--;
      else if (st[i][j] == '(')
        cnt++;
      if (cnt < 0) {
        f = 0;
      }
    }
    if (f) mp2[cnt]++;
  }
  ll ans(0);
  for (auto i : mp1) {
    ans += 1LL * i.second * mp2[i.first];
  }
  cout << ans << endl;
  return 0;
}
