#include <bits/stdc++.h>
using namespace std;
using namespace rel_ops;
const double PI = acos((double)-1);
int ts, ts2, ts3, ts4;
int n, m;
long long gcd(long long x, long long y) {
  long long t;
  for (; y != 0;) {
    t = x % y;
    x = y;
    y = t;
  }
  return x;
}
double sqr(double x) { return x * x; }
template <class T>
void mn(T& x, T y) {
  x = min(x, y);
}
template <class T>
void mx(T& x, T y) {
  x = max(x, y);
}
int a[100005];
int rakki(int x) {
  int i, j;
  for (; x; x /= 10)
    if (x % 10 != 4 && x % 10 != 7) return 0;
  return 1;
}
long long Basho[100005], nx[100005], pos2;
long long ans;
void work() {
  long long i, j, k, l, t1, t2, t3, t4, t5, t6, t7, t8, t9, t, nw;
  ans = 1;
  for (i = 1; i <= 4; i++) ans = (unsigned long long)ans * (n + 2 - i + 1) / i;
  pos2 = Basho[0];
  Basho[0] = 0;
  for (i = 1; i <= pos2; i++) {
    for (j = i + 1; j <= pos2; j++)
      if (a[Basho[j]] == a[Basho[i]]) break;
    nx[i] = j;
  }
  set<int> appe;
  for (i = 1; i <= pos2; i++) {
    if (i == pos2) continue;
    appe.clear();
    appe.insert(n + 1);
    appe.insert(Basho[i]);
    t1 = 0;
    if (i == 3) ts = 0;
    for (j = i; j >= 1; j--) {
      ans -= (Basho[j] - Basho[j - 1]) * t1;
      for (k = nx[j]; k <= pos2;) {
        if (k == nx[j] && k <= i) break;
        appe.insert(Basho[k]);
        typeof appe.begin() it = appe.find(Basho[k]), pr = (--it)++,
                            ne = (++it)--;
        if (pr == appe.begin()) {
          t2 = (long long)(*ne - Basho[k]) *
               ((long long)(Basho[i + 1] - Basho[i]) *
                (Basho[i + 1] - Basho[i] + 1) / 2);
          t2 += (long long)(*ne - Basho[k]) * (Basho[k] - Basho[i + 1]) *
                (Basho[i + 1] - Basho[i]);
          t1 += t2;
          ans -= (Basho[j] - Basho[j - 1]) * t2;
        } else {
          t2 = (*ne - Basho[k]) * (Basho[k] - *pr) * (Basho[i + 1] - Basho[i]);
          t1 += t2;
          ans -= (Basho[j] - Basho[j - 1]) * t2;
        }
        k = nx[k];
      }
    }
  }
}
int main() {
  int i, j, k, l, t1, t2, t3, t4, t5, t6, t7, t8, t9, t, nw;
  int tt1, tt2, tt3, tt4;
  double u1, u2, u3, u4, u5, u6, u7, u8, u9;
  char c1, c2, c3;
  srand((unsigned)time(0));
  cin >> n;
  Basho[Basho[0] = 0] = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (rakki(a[i])) Basho[++Basho[0]] = i;
  }
  work();
  cout << ans << endl;
  return 0;
}
