#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[51];
  long long int n, b, c, d, e, f, g;
  cin >> n;
  cin >> a;
  c = n / 2;
  e = 0;
  f = 0;
  for (b = 0; b < n; b++) {
    d = a[b] - '0';
    if (d != 4 && d != 7) {
      cout << "NO" << endl;
      return 0;
    } else {
      if (b < c)
        e = e + d;
      else
        f = f + d;
    }
  }
  if (e == f)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
