#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int> > hamko(n);
  for (int i = (int)(0); i < (int)(n); i++) {
    string s;
    cin >> s;
    int mi = 0, delta = 0;
    for (int i = (int)(0); i < (int)(s.length()); i++) {
      delta += s[i] == '(' ? 1 : -1;
      mi = min(mi, delta);
    }
    hamko[i] = pair<int, int>(delta, mi);
  }
  map<int, vector<int> > chino;
  for (int i = (int)(0); i < (int)(n); i++) {
    chino[hamko[i].first].push_back(hamko[i].second);
  }
  long long int tot = 0;
  for (auto &e : chino) {
    int key = e.first;
    if (key < 0) continue;
    vector<int> &vi = e.second;
    sort(vi.begin(), vi.end());
    if (key == 0) {
      long long int len = vi.end() - lower_bound(vi.begin(), vi.end(), 0);
      tot += len * len;
    } else {
      vector<int> &opp = chino[-key];
      sort(opp.begin(), opp.end());
      for (int mi : vi) {
        if (mi < 0) continue;
        long long int len =
            opp.end() - lower_bound(opp.begin(), opp.end(), -key);
        tot += len;
      }
    }
  }
  cout << tot << "\n";
}
