#include <bits/stdc++.h>
using namespace std;
const int N = 1200000;
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  vector<int> cso(N);
  vector<int> csc(N);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int opened = 0;
    int closed = 0;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == '(')
        opened++;
      else
        opened--;
      if (opened < 0) {
        opened = -1;
        break;
      }
    }
    for (int j = s.size() - 1; j >= 0; j--) {
      if (s[j] == ')')
        closed++;
      else
        closed--;
      if (closed < 0) {
        closed = -1;
        break;
      }
    }
    if (closed != -1) ans += cso[closed];
    if (opened != -1) ans += csc[opened];
    cso[opened]++;
    csc[closed]++;
    if (opened == closed and closed == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}
