#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  string v[n][2];
  for (long long i = 0; i < n; i++) {
    cin >> v[i][0];
    v[i][1] = v[i][0];
    reverse(v[i][1].begin(), v[i][1].end());
  }
  long long dp[n][2];
  for (long long i = 0; i < n; i++) {
    dp[i][0] = 1000000000000000007;
    dp[i][1] = 1000000000000000007;
  }
  dp[0][0] = 0;
  dp[0][1] = a[0];
  for (long long i = 1; i < n; i++) {
    for (long long j = 0; j < 2; j++) {
      if (v[i][j] >= v[i - 1][0]) dp[i][j] = min(dp[i][j], dp[i - 1][0]);
      if (v[i][j] >= v[i - 1][1]) dp[i][j] = min(dp[i][j], dp[i - 1][1]);
      if (dp[i][j] != 1000000000000000007) dp[i][j] += j * a[i];
    }
    if (dp[i][0] == 1000000000000000007 && dp[i][1] == 1000000000000000007) {
      cout << -1;
      return 0;
    }
  }
  cout << min(dp[n - 1][0], dp[n - 1][1]);
  return 0;
}
