#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  char s[51];
  while (cin >> n >> s) {
    int sum1 = 0, sum2 = 0, flag = 0;
    vector<int> v;
    for (int i = 0; i < n; i++) {
      char c = s[i];
      if (c != '4' && c != '7') {
        flag = 1;
        break;
      }
      if (i < n / 2) {
        sum1 += c - '0';
      } else
        sum2 += c - '0';
    }
    if (flag == 1 || sum1 != sum2)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
