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