#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, m;
  long a, b, c = 0, cc = 0, ccc = 0;
  long ar[100100];
  memset(ar, 0, sizeof(ar));
  long f = 0;
  string s, ss;
  cin >> n;
  cin >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] != '4' and s[i] != '7') {
      cout << "NO";
      return 0;
    }
  }
  for (int i = 0; i < n / 2; i++)
    if (s[i] == '4' or s[i] == '7') {
      c += (s[i] - '0');
    }
  for (int i = n / 2; i < n; i++)
    if (s[i] == '4' or s[i] == '7') {
      cc += (s[i] - '0');
    }
  if (c == cc)
    cout << "YES";
  else
    cout << "NO";
}
