#include <bits/stdc++.h>
using namespace std;
const int M = 200;
int n;
char s[M];
int main() {
  while (scanf("%d", &n) == 1) {
    scanf("%s", s);
    int len = strlen(s);
    int sum1 = 0, sum2 = 0;
    bool flag = true;
    for (int i = 0; i < len; i++) {
      if (s[i] != '4' && s[i] != '7') {
        flag = false;
        break;
      }
      if (i < len / 2) {
        sum1 += (s[i] - '0');
      } else {
        sum2 += (s[i] - '0');
      }
    }
    if (!flag) {
      puts("NO");
    } else {
      if (sum1 == sum2)
        puts("YES");
      else
        puts("NO");
    }
  }
  return 0;
}
