#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 300 * 1000 + 10;
set<pair<int, int>> x, y;
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int cnt = 0, a = 0;
    for (auto j : s) {
      if (j == '(')
        a++;
      else if (a)
        a--;
      else
        cnt++;
    }
    if (!a) x.insert({cnt, i});
    cnt = a = 0;
    reverse(s.begin(), s.end());
    for (auto j : s) {
      if (j == ')')
        a++;
      else if (a)
        a--;
      else
        cnt++;
    }
    if (!a) y.insert({cnt, i});
  }
  long long ans = 0;
  for (int i = 0; i < MAX_N; i++) {
    vector<pair<int, int>> a, b;
    for (auto j : x) {
      if (j.first == i)
        a.push_back(j);
      else
        break;
    }
    for (auto j : y) {
      if (j.first == i)
        b.push_back(j);
      else
        break;
    }
    for (auto j : a) x.erase(j);
    for (auto j : b) y.erase(j);
    ans += 1LL * a.size() * b.size();
  }
  cout << ans << endl;
  return 0;
}
