#include <bits/stdc++.h>
using namespace std;
int n, sum1, sum2, b = 1;
string s;
int main() {
  scanf("%d", &n);
  cin >> s;
  for (int i = 0; i < s.size() / 2; i++) {
    sum1 += s[i] - '0';
    if (s[i] != '4' and s[i] != '7') b = 0;
  }
  for (int i = s.size() / 2; i < s.size(); i++) {
    sum2 += s[i] - '0';
    if (s[i] != '4' and s[i] != '7') b = 0;
  }
  sum1 == sum2 and b ? printf("YES\n") : printf("NO\n");
}
