#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char a[n + 1];
  cin >> a;
  int i, f = 1;
  for (i = 1; i <= n; i++) {
    if ((a[i - 1] != '4') && (a[i - 1] != '7')) {
      f = 0;
      break;
    }
  }
  if (f == 1) {
    int s = 0, k = n / 2;
    for (i = 1; i <= k; i++) {
      s += a[i - 1];
      s -= a[i + k - 1];
    }
    if (s != 0) {
      f = 0;
    }
  }
  if (f == 0) {
    cout << "NO";
  } else {
    cout << "YES";
  }
  return 0;
}
