#include <bits/stdc++.h>
int a[300010], b[1000], c[1000];
using namespace std;
int main() {
  int n, i, j;
  string s;
  cin >> n;
  cin >> s;
  i = 0;
  while ((s[i] == '4') || (s[i] == '7')) {
    i++;
  }
  if (i != n)
    cout << "NO";
  else {
    if (n % 2 == 0) {
      int rez1 = 0;
      for (i = 0; i < n / 2; i++) {
        rez1 += int(s[i]);
      }
      int rez2 = 0;
      for (i = n / 2; i < n; i++) {
        rez2 += int(s[i]);
      }
      if (rez1 == rez2)
        cout << "YES";
      else
        cout << "NO";
    } else {
      int rez1 = 0;
      for (i = 0; i < n / 2; i++) {
        rez1 += int(s[i]);
      }
      int rez2 = 0;
      for (i = n / 2 + 1; i < n; i++) {
        rez2 += int(s[i]);
      }
      if (rez1 == rez2)
        cout << "YES";
      else
        cout << "NO";
    }
  }
  return 0;
}
